[PATCH] nscd: Deallocate existing user names in file parser
Florian Weimer
fw@deneb.enyo.de
Mon Aug 13 20:01:00 GMT 2018
* DJ Delorie:
> fweimer@redhat.com (Florian Weimer) writes:
>> - server_user = xstrdup (arg1);
>> + {
>> + free ((char *) server_user);
>> + server_user = xstrdup (arg1);
>> + }
>
> server_user is global and unitialized, so initialized to NULL. free()
> allows the passed pointer to be NULL. So this is OK.
>
> Note that free() nominally takes a void*, not a char*. I think we
> should use void* in this case.
My idea was to make clear that I'm casting away const here (similar to
C++'s const_cast).
More information about the Libc-alpha
mailing list