]> git.tuebingen.mpg.de Git - paraslash.git/commit
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)
commit746cf9c9c89b8b0c6f39b8ec3f07a0386e61a8ae
tree5f78c1c7bbaa58079d99d2ec6f69d29992408b1a
parent86595f65b445fb587489c863e93ad2b2337d7497
server: Fix memory leak in com_check().

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.
mood.c