On 2022-11-04 16:11, Guy Harris via tz wrote:
In what cases in zic is emalloc() - or erealloc() - called with 0 as the size argument?
It's when zic sees a Zone with no continuation lines. I didn't notice the bug in testing, since I don't test with AIX. The portability bug was triggered by the removal of the Qt bug workaround in tzcode 2022f, which when combined with the -bslim option introduced in tzcode 2019b means that zic can generate TZif files with no time transitions. Thanks for reporting the bug, Tim. I installed the first attached patch; please give it a try. I think this fixes the only place that might call malloc(0) or realloc(p, 0). It's unfortunate that the C standard allows malloc to return NULL on success, as this complicates error checking. Of course zic.c should be portable even to platforms that exploit this glitch in C.
(ecpyalloc() - which should probably be called estrdup() to make it clearer that it's "strdup() with quit on out-of-memory"
Good suggestion, thanks. I installed the attached second patch to do that.