diff mbox series

[LEDE-DEV,2/2] libubox: Plug a small memory leak.

Message ID 1517554332-15236-2-git-send-email-rosenp@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series [LEDE-DEV,1/2] libubox: Don't warn about sign comparisons. | expand

Commit Message

Rosen Penev Feb. 2, 2018, 6:52 a.m. UTC
va_end was not called if calloc fails.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 utils.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils.c b/utils.c
index 765dd8b..c22250d 100644
--- 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];