[PATCH weston 2/2] main: don't leak option strings
Bill Spitzak
spitzak at gmail.com
Mon Sep 8 11:00:37 PDT 2014
On 09/07/2014 11:28 PM, Pekka Paalanen wrote:
>> I think it is safe to assume the contents of argv will not get overwritten.
>>
>> It is common to copy argv itself and modify that, but not to modify the
>> strings it points at.
>
> This would be feasible only if we can guarantee that no-one will ever
> need to store a dynamically allocated string to any of the assigned
> variables. If something produces a dynamically allocated string, then
> you would need to track if you can free() the string or not.
Or you can just leak that dynamically allocated value, which is what I
would do.
Trying to shut up valgrind on exit is an exercise in futility and adding
a free() to try to shut it up often requires lots of unwanted code
changes as this demonstrates.
Any way it is not a big deal and any real system will probably be based
on string objects of some sort. It sounds like you should also change
the parse_options to copy all the string arguments too.
More information about the wayland-devel
mailing list