[tz] Bug in 2022f version of zic.c

Guy Harris gharris at sonic.net
Fri Nov 4 23:11:04 UTC 2022


On Nov 4, 2022, at 11:28 AM, Tim McBrayer via tz <tz at iana.org> wrote:

> tzcode2022f/zic.c has a bug in its memory checker routine in static void* memcheck(void*). This code throws an error and exits when the pointer returned by malloc is NULL. However, malloc is allowed to return a NULL pointer when the allocation size is 0. And, on one machine I am building the TZ code on, malloc(0) does indeed return NULL. This is an AIX 6.1 box, with C compiler xlC 13.01.0000.0011.
> 
> This is easy enough to work around locally.

In what cases in zic is emalloc() - or erealloc() - called with 0 as the size argument?  If there are any, are any where it *should* be doing that, rather than just skipping whatever it's doing if there zero items/bytes/whatever on which to do it?

(ecpyalloc() - which should probably be called estrdup() to make it clearer that it's "strdup() with quit on out-of-memory" - is safe, as even strdup("") returns NULL only if the allocation fails.)


More information about the tz mailing list