nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone

Blame SOURCES/bash-5.0-histtimeformat-segfault.patch

6de7cf
diff --git a/builtins/history.def b/builtins/history.def
6de7cf
--- a/builtins/history.def
6de7cf
+++ b/builtins/history.def
6de7cf
@@ -256,10 +256,13 @@ histtime (hlist, histtimefmt)
6de7cf
 {
6de7cf
   static char timestr[128];
6de7cf
   time_t t;
6de7cf
+  struct tm *tm;
6de7cf
 
6de7cf
   t = history_get_time (hlist);
6de7cf
-  if (t)
6de7cf
-    strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t);;
6de7cf
+
6de7cf
+  tm = t ? localtime (&t) : 0;
6de7cf
+  if (t && tm)
6de7cf
+    strftime (timestr, sizeof (timestr), histtimefmt, tm);
6de7cf
   else if (hlist->timestamp && hlist->timestamp[0])
6de7cf
     snprintf (timestr, sizeof (timestr), _("%s: invalid timestamp"),
6de7cf
 	(hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);