From c334cb626d8a7c193453fac8a70cc7cdcd8a3f4e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 13 May 2012 22:40:50 +0000 Subject: Gracefully handle allocation failure. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4393 a436a847-0d15-0410-975c-d299462d15a1 --- src/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 789f5a6..b534ffd 100644 --- a/src/util.c +++ b/src/util.c @@ -65,7 +65,12 @@ lilv_strjoin(const char* first, ...) break; const size_t this_len = strlen(s); - result = (char*)realloc(result, len + this_len + 1); + if (!(result = (char*)realloc(result, len + this_len + 1))) { + free(result); + LILV_ERROR("realloc() failed\n"); + return NULL; + } + memcpy(result + len, s, this_len); len += this_len; } -- cgit v1.2.1