]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/EfiUtilityMsgs.c
BaseTools/C/Common: Fix potential memory leak
[mirror_edk2.git] / BaseTools / Source / C / Common / EfiUtilityMsgs.c
index dc9b0ffaa26bf2154ddbd7979d9575299405c360..7b4c2310ca9fd2c974fe6d4ba370f89e056ca43d 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+EFI tools utility functions to display warning, error, and informational messages\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -9,15 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  EfiUtilityMsgs.c\r
-\r
-Abstract:\r
-\r
-  EFI tools utility functions to display warning, error, and informational\r
-  messages.\r
-\r
 --*/\r
 \r
 #include <stdio.h>\r
@@ -459,14 +451,16 @@ Notes:
     //\r
     time (&CurrentTime);\r
     NewTime = localtime (&CurrentTime);\r
-    fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",\r
-                     NewTime->tm_year + 1900,\r
-                     NewTime->tm_mon + 1,\r
-                     NewTime->tm_mday,\r
-                     NewTime->tm_hour,\r
-                     NewTime->tm_min,\r
-                     NewTime->tm_sec\r
-                     );\r
+    if (NewTime != NULL) {\r
+      fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",\r
+                       NewTime->tm_year + 1900,\r
+                       NewTime->tm_mon + 1,\r
+                       NewTime->tm_mday,\r
+                       NewTime->tm_hour,\r
+                       NewTime->tm_min,\r
+                       NewTime->tm_sec\r
+                       );\r
+    }\r
     if (Cptr != NULL) {\r
       sprintf (Line, ": %s", Cptr);\r
       if (LineNumber != 0) {\r