This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
d_localtime_r.U - explicitly free() allocations 71/head
authorRichard Leach <richardleach@users.noreply.github.com>
Wed, 2 Sep 2020 12:24:03 +0000 (13:24 +0100)
committerGitHub <noreply@github.com>
Wed, 2 Sep 2020 12:24:03 +0000 (13:24 +0100)
To keep LeakSanitizer happy. See https://github.com/Perl/perl5/issues/18107 for background.

U/threads/d_localtime_r.U

index de51966..53fa397 100644 (file)
@@ -132,6 +132,7 @@ REENTRANT_PROTO*)
 #endif
 int main()
 {
+    int result = 0;
     time_t t = time(0L);
     char w_tz[]="TZ" "=GMT+5",
         e_tz[]="TZ" "=GMT-5",
@@ -150,8 +151,10 @@ int main()
     localtime_r(&t, &tm_w);
 
     if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
-       return 1;
-    return 0;
+       result = 1;
+
+    free(tz_e);free(tz_w);
+    return result;
 }
 EOCP
        set try