diff options
author | David Robillard <d@drobilla.net> | 2016-09-18 15:13:52 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-09-18 15:13:52 -0400 |
commit | 7ce645cfe6fffef55eb43e1e2b63e4ac41c8581c (patch) | |
tree | dd5b03025c8984da6b52f5d1653ac140bf81c7e1 /src/state.c | |
parent | 7a68f1e59abd84574d8b8ccf6289b6c01bf428c6 (diff) | |
download | lilv-7ce645cfe6fffef55eb43e1e2b63e4ac41c8581c.tar.gz lilv-7ce645cfe6fffef55eb43e1e2b63e4ac41c8581c.tar.bz2 lilv-7ce645cfe6fffef55eb43e1e2b63e4ac41c8581c.zip |
Fix memory, file, and library leaks
Diffstat (limited to 'src/state.c')
-rw-r--r-- | src/state.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/state.c b/src/state.c index b852a31..7a8abc0 100644 --- a/src/state.c +++ b/src/state.c @@ -245,6 +245,7 @@ abstract_path(LV2_State_Map_Path_Handle handle, char* copy = lilv_get_latest_copy(real_path, cpath); if (!copy || !lilv_file_equals(real_path, copy)) { // No recent enough copy, make a new one + free(copy); copy = lilv_find_free_path(cpath, lilv_path_exists, NULL); const int st = lilv_copy_file(real_path, copy); if (st) { @@ -1204,11 +1205,13 @@ lilv_state_delete(LilvWorld* world, } static void -free_property_array(PropertyArray* array) +free_property_array(LilvState* state, PropertyArray* array) { for (uint32_t i = 0; i < array->n; ++i) { - if (array->props[i].flags & LV2_STATE_IS_POD) { - free(array->props[i].value); + Property* prop = &array->props[i]; + if ((prop->flags & LV2_STATE_IS_POD) || + prop->type == state->atom_Path) { + free(prop->value); } } free(array->props); @@ -1218,8 +1221,8 @@ LILV_API void lilv_state_free(LilvState* state) { if (state) { - free_property_array(&state->props); - free_property_array(&state->metadata); + free_property_array(state, &state->props); + free_property_array(state, &state->metadata); for (uint32_t i = 0; i < state->n_values; ++i) { free(state->values[i].value); free(state->values[i].symbol); |