mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
Parser: don't leak extra data key/value pairs
On parsing of dive computer extra data, key/value pairs are stored in global state. They are added to the dive computer with add_extra_data(), which makes a copy of the string. The local copies of the strings are never freed. free() the strings after storing them. The data still leaks in case of unfinished parsing of extra_data tags, but this will be taken care of in a subsequent commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6fd663f9b3
commit
5a65bb75da
1 changed files with 3 additions and 0 deletions
|
@ -270,6 +270,9 @@ static void extra_data_end(void)
|
||||||
// don't save partial structures - we must have both key and value
|
// don't save partial structures - we must have both key and value
|
||||||
if (cur_extra_data.key && cur_extra_data.value)
|
if (cur_extra_data.key && cur_extra_data.value)
|
||||||
add_extra_data(get_dc(), cur_extra_data.key, cur_extra_data.value);
|
add_extra_data(get_dc(), cur_extra_data.key, cur_extra_data.value);
|
||||||
|
free((void *)cur_extra_data.key);
|
||||||
|
free((void *)cur_extra_data.value);
|
||||||
|
cur_extra_data.key = cur_extra_data.value = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void weight(char *buffer, weight_t *weight)
|
static void weight(char *buffer, weight_t *weight)
|
||||||
|
|
Loading…
Reference in a new issue