[tz] [PROPOSED PATCH] Make the library thread-safe if THREAD_SAFE is defined.
wharms at bfs.de
Mon Aug 18 17:43:33 UTC 2014
Am 18.08.2014 16:44, schrieb Paul Eggert:
> walter harms wrote:
>> maybe lclptr = calloc(sizeof *lclptr,1); ?
>> that would remove the need for lclptr->leapcnt = 0; etc.
>> any information leak via padding bytes would be closed also.
> Sorry, I don't see the information leak here, as lclptr is static and
> does not escape to calling code.
I have no idea either but i prefer defensive coding.
> More generally, the current code always uses malloc to allocate objects
> dynamically, and switching to calloc would be a pragmatics change that
> should be done as a separate patch.
sorry, i had the impression that the patch was up to discussion.
> I'm not entirely sold on the idea of using calloc to avoid leaking
> information from previous uses of the memory. If information leakage is
> a concern, surely it's better to use a malloc wrapper that clears memory
> rather than to manually inspect and modify every call to malloc.
information leak is not the primary concern, in this case it would simply
mean that every field is already 0 no need to do this manually,
saving a few bytes.
More information about the tz