libxl: fix double free on some config parser errors
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 31 Aug 2012 11:24:57 +0000 (12:24 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 31 Aug 2012 11:24:57 +0000 (12:24 +0100)
commit50188cde05e6f0f039d3d848c3acf9b2a6e21365
tree1a2cf151433e4227ab80e1673ffd5a8aaf717957
parentf185a527caf966e10538d342eb677ccc4875200c
libxl: fix double free on some config parser errors

If libxlu_cfg_y.y encountered a config file error, the code generated
by bison would sometimes _both_ run the %destructor _and_ call
xlu__cfg_set_store for the same XLU_ConfigSetting* semantic value.
The result would be a double free.

This appears to be because of the use of a mid-rule action.  There is
some discussion of the problems with destructors and mid-rule action
error handling in "(bison)Mid-Rule Actions".  This area is complex and
best avoided.

So fix the bug by abolishing the use of a mid-rule action, which was
in any case not necessary here.

Also while we are there rename the nonterminal rule "setting" to
"assignment", to avoid confusion with the token type "setting", which
had an identically name in a different namespace.  This was especially
confusing because the nonterminal "setting" did not have "setting" as
the type of its semantic value!  (In fact the nonterminal, now called
"assignment", does not have a value so it does not have a value type.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxlu_cfg_y.c
tools/libxl/libxlu_cfg_y.y