]> granicus.if.org Git - musl/commitdiff
minor fix to tz name checking
authorRich Felker <dalias@aerifal.cx>
Sat, 24 Aug 2013 17:10:01 +0000 (13:10 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 24 Aug 2013 17:10:01 +0000 (13:10 -0400)
if a zoneinfo file is not (or is no longer) in use, don't check the
abbrevs pointers, which may be invalid.

src/time/__tz.c

index dfeac519641fb11ad19cdbf527f453bfd53d9c82..8a1836e7178615d1ebb48d947709a48499e0bb51 100644 (file)
@@ -395,8 +395,8 @@ const char *__tm_to_tzname(const struct tm *tm)
        const void *p = tm->__tm_zone;
        LOCK(lock);
        do_tzset();
-       if (p != __gmt && p != __tzname[0] && p != __tzname[1]
-           && (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs)
+       if (p != __gmt && p != __tzname[0] && p != __tzname[1] &&
+           (!zi || (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs))
                p = "";
        UNLOCK(lock);
        return p;