From 36ddbdbbe2082f8832218e70ae0d62f6e77c7a28 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 10 Feb 2012 13:56:19 +0000 Subject: Return error for failing allocation Fix case, where final strdup would have failed and it would miss to return failure for this case and return success and NULL pointer. --- libdm/libdm-string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libdm/libdm-string.c') diff --git a/libdm/libdm-string.c b/libdm/libdm-string.c index 67eabf5d..d9b444c1 100644 --- a/libdm/libdm-string.c +++ b/libdm/libdm-string.c @@ -156,7 +156,9 @@ int dm_asprintf(char **result, const char *format, ...) } } - *result = dm_strdup(buf); + if (!(*result = dm_strdup(buf))) + n = -2; /* return -1 */ + dm_free(buf); return n + 1; } -- cgit