mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
cleanup: leak fix in taxonomy_set_country()
When overwriting a country, the old string was not freed. Fix this. Contains an unrelated coding-style fix: use braces if code block contains more than one line. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b1a1dc3639
commit
86c24dd832
1 changed files with 4 additions and 1 deletions
|
@ -65,9 +65,10 @@ void copy_taxonomy(const struct taxonomy_data *orig, struct taxonomy_data *copy)
|
|||
|
||||
int taxonomy_index_for_category(const struct taxonomy_data *t, enum taxonomy_category cat)
|
||||
{
|
||||
for (int i = 0; i < t->nr; i++)
|
||||
for (int i = 0; i < t->nr; i++) {
|
||||
if (t->category[i].category == cat)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -90,6 +91,8 @@ void taxonomy_set_country(struct taxonomy_data *t, const char *country, enum tax
|
|||
|
||||
for (int i = 0; i < t->nr; i++) {
|
||||
if (t->category[i].category == TC_COUNTRY) {
|
||||
free((void *)t->category[i].value);
|
||||
t->category[i].value = NULL;
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue