libubox: Plug a small memory leak.
authorRosen Penev <rosenp@gmail.com>
Fri, 2 Feb 2018 06:52:12 +0000 (22:52 -0800)
committerJohn Crispin <john@phrozen.org>
Sun, 11 Feb 2018 15:39:35 +0000 (16:39 +0100)
va_end was not called if calloc fails.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
utils.c

diff --git a/utils.c b/utils.c
index 765dd8bcb921b133aa320fddcada0bd3422b63e5..c22250d27ec78265b6a5ece8497b26f907cabff1 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -47,8 +47,11 @@ void *__calloc_a(size_t len, ...)
        va_end(ap1);
 
        ptr = calloc(1, alloc_len);
-       if (!ptr)
+       if (!ptr) {
+               va_end(ap);
                return NULL;
+       }
+
        alloc_len = 0;
        foreach_arg(ap, cur_addr, cur_len, &ret, len) {
                *cur_addr = &ptr[alloc_len];