mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Clear memory allocated for event names
parse-xml.c: When parsing events, we allocate memory for the event 'name' attribute, but also have to free this memory eventually. Let's do that in event_end() right after add_event() is called. Fixes a long-running memory leak in the parser. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
720d4c65e8
commit
cc3b87c044
1 changed files with 7 additions and 4 deletions
11
parse-xml.c
11
parse-xml.c
|
@ -1096,10 +1096,13 @@ static struct divecomputer *get_dc(void)
|
|||
static void event_end(void)
|
||||
{
|
||||
struct divecomputer *dc = get_dc();
|
||||
if (cur_event.name && strcmp(cur_event.name, "surface") != 0)
|
||||
add_event(dc, cur_event.time.seconds,
|
||||
cur_event.type, cur_event.flags,
|
||||
cur_event.value, cur_event.name);
|
||||
if (cur_event.name) {
|
||||
if (strcmp(cur_event.name, "surface") != 0)
|
||||
add_event(dc, cur_event.time.seconds,
|
||||
cur_event.type, cur_event.flags,
|
||||
cur_event.value, cur_event.name);
|
||||
free((void *)cur_event.name);
|
||||
}
|
||||
cur_event.active = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue