]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix lifetime bug in tzlookup
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Jul 2016 21:38:12 +0000 (23:38 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Jul 2016 21:38:44 +0000 (23:38 +0200)
* src/editfns.c (tzlookup): Fix storage lifetime bug when
INTEGERP (zone) && settz.  Problem found by Coverity Scan.

src/editfns.c

index aed884ebe1c40d7b339eb9118d7b23c05e48f5d8..61b2a871b73669acb578d3b55d2e3af5f77a03eb 100644 (file)
@@ -146,6 +146,9 @@ xtzfree (timezone_t tz)
 static timezone_t
 tzlookup (Lisp_Object zone, bool settz)
 {
+  static char const tzbuf_format[] = "<%+.*"pI"d>%s%"pI"d:%02d:%02d";
+  char const *trailing_tzbuf_format = tzbuf_format + sizeof "<%+.*"pI"d" - 1;
+  char tzbuf[sizeof tzbuf_format + 2 * INT_STRLEN_BOUND (EMACS_INT)];
   char const *zone_string;
   timezone_t new_tz;
 
@@ -158,9 +161,6 @@ tzlookup (Lisp_Object zone, bool settz)
     }
   else
     {
-      static char const tzbuf_format[] = "<%+.*"pI"d>%s%"pI"d:%02d:%02d";
-      char const *trailing_tzbuf_format = tzbuf_format + sizeof "<%+.*"pI"d" - 1;
-      char tzbuf[sizeof tzbuf_format + 2 * INT_STRLEN_BOUND (EMACS_INT)];
       bool plain_integer = INTEGERP (zone);
 
       if (EQ (zone, Qwall))