summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-04-15 21:30:42 +0200
committerDavid Robillard <d@drobilla.net>2019-04-15 23:03:10 +0200
commit123faa561b6fad8e510dd0bc00df40fdd5d0574d (patch)
tree2e9c4aacc17a4e70388b614545d85e19f80c6292
parentf5af942a11bd2f3b718adf70ca15c4a62372ee78 (diff)
downloadlilv-123faa561b6fad8e510dd0bc00df40fdd5d0574d.tar.gz
lilv-123faa561b6fad8e510dd0bc00df40fdd5d0574d.tar.bz2
lilv-123faa561b6fad8e510dd0bc00df40fdd5d0574d.zip
Fix mismatched malloc/free calls
-rw-r--r--src/instance.c4
-rw-r--r--src/state.c6
-rw-r--r--test/test.lv2/test.c26
3 files changed, 23 insertions, 13 deletions
diff --git a/src/instance.c b/src/instance.c
index ac263c7..75c550c 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -47,7 +47,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
LilvLib* lib = lilv_lib_open(plugin->world, lib_uri, bundle_path, features);
if (!lib) {
- lilv_free(bundle_path);
+ serd_free(bundle_path);
return NULL;
}
@@ -81,7 +81,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
}
free(local_features);
- lilv_free(bundle_path);
+ serd_free(bundle_path);
if (result) {
if (result->lv2_handle == NULL) {
diff --git a/src/state.c b/src/state.c
index f2b88e7..57c4b86 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1194,10 +1194,10 @@ lilv_state_delete(LilvWorld* world,
model, state->uri->node, world->uris.rdfs_seeAlso, NULL, NULL);
if (file) {
// Remove state file
- char* path = lilv_file_uri_parse(
- (const char*)sord_node_get_string(file), NULL);
+ char* path =
+ (char*)serd_file_uri_parse(sord_node_get_string(file), NULL);
try_unlink(path);
- lilv_free(path);
+ serd_free(path);
}
// Remove any existing manifest entries for this state
diff --git a/test/test.lv2/test.c b/test/test.lv2/test.c
index 36be747..f15b4dd 100644
--- a/test/test.lv2/test.c
+++ b/test/test.lv2/test.c
@@ -59,13 +59,23 @@ typedef struct {
} Test;
static void
+free_path(char* path)
+{
+ /* FIXME: Temporary hack to avoid mismatched malloc/free crashes on
+ Windows. The specifications needs a feature for this. */
+#ifndef _WIN32
+ free(path);
+#endif
+}
+
+static void
cleanup(LV2_Handle instance)
{
Test* test = (Test*)instance;
if (test->rec_file) {
fclose(test->rec_file);
}
- free(test->rec_file_path);
+ free_path(test->rec_file_path);
free(instance);
}
@@ -250,8 +260,8 @@ save(LV2_Handle instance,
map_uri(plugin, LV2_ATOM__Path),
LV2_STATE_IS_POD);
- free(apath);
- free(apath2);
+ free_path(apath);
+ free_path(apath2);
if (plugin->rec_file) {
fflush(plugin->rec_file);
@@ -265,7 +275,7 @@ save(LV2_Handle instance,
map_uri(plugin, LV2_ATOM__Path),
LV2_STATE_IS_POD);
- free(apath);
+ free_path(apath);
}
if (make_path) {
@@ -281,8 +291,8 @@ save(LV2_Handle instance,
strlen(apath) + 1,
map_uri(plugin, LV2_ATOM__Path),
LV2_STATE_IS_POD);
- free(apath);
- free(spath);
+ free_path(apath);
+ free_path(spath);
}
}
@@ -338,7 +348,7 @@ restore(LV2_Handle instance,
fprintf(stderr, "error: Restored bad file contents `%s' != `Hello'\n",
str);
}
- free(path);
+ free_path(path);
}
apath = (char*)retrieve(
@@ -353,7 +363,7 @@ restore(LV2_Handle instance,
} else {
fclose(sfile);
}
- free(spath);
+ free_path(spath);
} else {
fprintf(stderr, "error: Failed to restore save file.\n");
}