From 3230f367b09e5b9476253176fa51123e90acb5d2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 26 Aug 2014 12:48:16 -0700 Subject: [PROPOSED PATCH 2/4] * localtime.c (zoneinit, tzalloc): Return NULL on failure. Suggested by Jonathan Lennox in: http://mm.icann.org/pipermail/tz/2014-August/021529.html --- localtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/localtime.c b/localtime.c index e294a9e..2434167 100644 --- a/localtime.c +++ b/localtime.c @@ -1191,7 +1191,7 @@ zoneinit(struct state *sp, char const *name) strcpy(sp->chars, gmt); } else if (! (tzload(name, sp, true) || (name && name[0] != ':' && tzparse(name, sp, false)))) - gmtload(sp); + return NULL; } return sp; } @@ -1264,7 +1264,10 @@ timezone_t tzalloc(char const *name) { timezone_t sp = malloc(sizeof *sp); - return zoneinit(sp, name); + timezone_t tp = sp ? zoneinit(sp, name) : sp; + if (!tp) + free(sp); + return tp; } void -- 1.9.1