summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-17 06:43:53 +0000
committerDavid Robillard <d@drobilla.net>2014-11-17 06:43:53 +0000
commit48e05557b8afac26bcdd0416ef0ab9a18037e529 (patch)
treec4430f6317092b41a8381ed15502f4dde8e86f29
parentee04d3ddaf6ad278000cad7acd413f76b6bfc535 (diff)
downloadlilv-48e05557b8afac26bcdd0416ef0ab9a18037e529.tar.gz
lilv-48e05557b8afac26bcdd0416ef0ab9a18037e529.tar.bz2
lilv-48e05557b8afac26bcdd0416ef0ab9a18037e529.zip
Fix a few minor/unlikely memory errors.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5484 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--NEWS3
-rw-r--r--src/instance.c2
-rw-r--r--src/util.c6
-rw-r--r--utils/lv2bench.c4
4 files changed, 11 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index f4a8ce7..0663e4e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
lilv (0.20.1) unstable;
* Tolerate passing NULL to lilv_state_restore()
+ * Fix a few minor/unlikely memory errors
* Configure based on compiler target OS for cross-compilation
* Minor documentation improvements
- -- David Robillard <d@drobilla.net> Sat, 04 Oct 2014 23:27:33 -0400
+ -- David Robillard <d@drobilla.net> Mon, 17 Nov 2014 01:43:02 -0500
lilv (0.20.0) stable;
diff --git a/src/instance.c b/src/instance.c
index 88a94fb..a3e2c91 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -51,7 +51,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
const LV2_Feature** local_features = NULL;
if (features == NULL) {
- local_features = (const LV2_Feature**)malloc(sizeof(LV2_Feature));
+ local_features = (const LV2_Feature**)malloc(sizeof(LV2_Feature*));
local_features[0] = NULL;
}
diff --git a/src/util.c b/src/util.c
index f1c9c1c..b38e58a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -68,13 +68,15 @@ lilv_strjoin(const char* first, ...)
if (s == NULL)
break;
- const size_t this_len = strlen(s);
- if (!(result = (char*)realloc(result, len + this_len + 1))) {
+ const size_t this_len = strlen(s);
+ char* new_result = (char*)realloc(result, len + this_len + 1);
+ if (!new_result) {
free(result);
LILV_ERROR("realloc() failed\n");
return NULL;
}
+ result = new_result;
memcpy(result + len, s, this_len);
len += this_len;
}
diff --git a/utils/lv2bench.c b/utils/lv2bench.c
index 30a4aaf..e585fbd 100644
--- a/utils/lv2bench.c
+++ b/utils/lv2bench.c
@@ -95,6 +95,7 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
fprintf(stderr, "<%s> requires feature <%s>, skipping\n",
uri, lilv_node_as_uri(feature));
free(buf);
+ uri_table_destroy(&uri_table);
return 0.0;
}
}
@@ -104,6 +105,7 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
fprintf(stderr, "Failed to instantiate <%s>\n",
lilv_node_as_uri(lilv_plugin_get_uri(p)));
free(buf);
+ uri_table_destroy(&uri_table);
return 0.0;
}
@@ -128,6 +130,7 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
lilv_instance_free(instance);
free(buf);
free(controls);
+ uri_table_destroy(&uri_table);
return 0.0;
}
} else if (lilv_port_is_a(p, port, atom_AtomPort)) {
@@ -138,6 +141,7 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
lilv_instance_free(instance);
free(buf);
free(controls);
+ uri_table_destroy(&uri_table);
return 0.0;
}
}