This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Hash::Util::FieldHash 1.03 leaks SVs which are used as object IDs stored in mg->mg_obj
[perl5.git] / time64.c
old mode 100644 (file)
new mode 100755 (executable)
index 3ac6707..0f58812
--- a/time64.c
+++ b/time64.c
@@ -165,6 +165,7 @@ Time64_T timegm64(struct TM *date) {
 }
 
 
+#ifdef DEBUGGING
 static int check_tm(struct TM *tm)
 {
     /* Don't forget leap seconds */
@@ -196,6 +197,7 @@ static int check_tm(struct TM *tm)
 
     return 1;
 }
+#endif
 
 
 /* The exceptional centuries without leap years cause the cycle to
@@ -332,6 +334,7 @@ void copy_big_TM_to_little_tm(const struct TM *src, struct tm *dest) {
 
 /* Simulate localtime_r() to the best of our ability */
 struct tm * fake_localtime_r(const time_t *clock, struct tm *result) {
+    dTHX;    /* in case the following is defined as Perl_my_localtime(aTHX_ ...) */
     const struct tm *static_result = localtime(clock);
 
     assert(result != NULL);
@@ -349,6 +352,7 @@ struct tm * fake_localtime_r(const time_t *clock, struct tm *result) {
 
 /* Simulate gmtime_r() to the best of our ability */
 struct tm * fake_gmtime_r(const time_t *clock, struct tm *result) {
+    dTHX;    /* in case the following is defined as Perl_my_gmtime(aTHX_ ...) */
     const struct tm *static_result = gmtime(clock);
 
     assert(result != NULL);
@@ -378,7 +382,7 @@ struct TM *gmtime64_r (const Time64_T *in_time, struct TM *p)
 
     /* Use the system gmtime() if time_t is small enough */
     if( SHOULD_USE_SYSTEM_GMTIME(*in_time) ) {
-        time_t safe_time = *in_time;
+        time_t safe_time = (time_t)*in_time;
         struct tm safe_date;
         GMTIME_R(&safe_time, &safe_date);
 
@@ -503,7 +507,7 @@ struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm)
 
     /* Use the system localtime() if time_t is small enough */
     if( SHOULD_USE_SYSTEM_LOCALTIME(*time) ) {
-        safe_time = *time;
+        safe_time = (time_t)*time;
 
         TRACE1("Using system localtime for %lld\n", *time);
 
@@ -530,7 +534,7 @@ struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm)
         gm_tm.tm_year = safe_year((Year)(gm_tm.tm_year + 1900)) - 1900;
     }
 
-    safe_time = timegm64(&gm_tm);
+    safe_time = (time_t)timegm64(&gm_tm);
     if( LOCALTIME_R(&safe_time, &safe_date) == NULL ) {
         TRACE1("localtime_r(%d) returned NULL\n", (int)safe_time);
         return NULL;