Fix for warnings in util.c/Perl_init_tm()
Steve Peters [Fri, 22 Apr 2005 22:36:03 +0000 (17:36 -0500)]
Message-Id:  <20050423033603.GA32547@mccoy.peters.homeunix.org>

localtime() can return null

p4raw-id: //depot/perl@24307

util.c

diff --git a/util.c b/util.c
index 5c1cdea..db56204 100644 (file)
--- a/util.c
+++ b/util.c
@@ -3355,7 +3355,9 @@ Perl_init_tm(pTHX_ struct tm *ptm)        /* see mktime, strftime and asctime */
 #ifdef HAS_TM_TM_ZONE
     Time_t now;
     (void)time(&now);
-    Copy(localtime(&now), ptm, 1, struct tm);
+    struct tm* my_tm = localtime(&now);
+    if (my_tm)
+        Copy(my_tm, ptm, 1, struct tm);
 #endif
 }