server: Fix memory leak in com_check().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2017 19:24:03 +0000 (21:24 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 8 Aug 2017 10:33:04 +0000 (12:33 +0200)
parse_mood_line() is called by the select command to set up a mood
item structure for each line of the mood definition. The item is stored
in one of the three lists of the mood structure provided by the caller.

The check command also calls parse_mood_line() to verify the mood
definitions. However, since it does not create a new mood, it does
not allocate a mood structure and passes a null pointer instead.

parse_mood_line() frees the mood item in the error case, but misses
to do so if a successfully parsed mood line was not added to any of
the three lists because the mood pointer is NULL, leaking the mood
item. This commit plugs the leak by adjusting the condition on which
to free the mood item.

This bug was introduced 10 years ago when mood checking was implemented
in commit 02baea14. It was found by code inspection.


No differences found