[PATCH weston 2/2] main: don't leak option strings

Bill Spitzak spitzak at gmail.com
Tue Sep 9 12:18:24 PDT 2014


On 09/08/2014 11:49 PM, Pekka Paalanen wrote:

> parse_options() already strdups() all strings it returns, which is one
> reason why I would not go removing the strdups.

You are right it already does that. Did not realize it even though I 
worked some on that code. I figured it was doing pointer copying.

The main problem is that if you execute "p = strdup(string)" twice, the 
old value of p will be leaked anyway, unless you add even more code to 
free the old version. I guess this should be fixed in parse_options and 
the the config file parser, though it is an example of how plugging 
these leaks is a nearly endless task.


More information about the wayland-devel mailing list