On Mon, Nov 25, 2019 at 09:17:51PM +0100, Tim Düsterhus wrote: > Willy, > > Am 25.11.19 um 17:57 schrieb Willy Tarreau: > > I agree that it's cleaner this way, however it then uncovers another > > issue which is that *if* ever called with a NULL err then it will leak > > memory. William said in the issue discussion that the functions are not > > Will it actually leak memory? `memprintf` is a no-op if the given `char > **out` is NULL. That is: It won't allocate anything.
Ah you're right, sorry. I always make this confusion because its initial implementation behave like this and it was painful to use, so it changed but I must have been traumatized by the old behavior as you see :-) > Unless my C foo totally leaves me right now only if the functions are > being passed a valid pointer to a null pointer (*err = NULL) there will > be a leak if the caller does not free the memory at *err after it has > possibly been re-allocated by `memprintf`. You're totally right. Then your patch is OK and I'm applying it. Thanks! Willy