From 48e05557b8afac26bcdd0416ef0ab9a18037e529 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 17 Nov 2014 06:43:53 +0000 Subject: Fix a few minor/unlikely memory errors. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5484 a436a847-0d15-0410-975c-d299462d15a1 --- src/instance.c | 2 +- src/util.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.1