[lxc-devel] [lxc/master] utils: fix memory leak for lxc_grow_array

d00349659 on Github lxc-bot at linuxcontainers.org
Sat Nov 2 06:31:30 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 336 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191101/f783abeb/attachment.bin>
-------------- next part --------------
From 6f4c331b1ef939d926becd2dc77a15fd408c48bb Mon Sep 17 00:00:00 2001
From: dongxinhua 00349659 <dongxinhua at huawei.com>
Date: Sat, 2 Nov 2019 14:27:14 +0800
Subject: [PATCH] utils: fix memory leak of lxc_grow_array

---
 src/lxc/string_utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lxc/string_utils.c b/src/lxc/string_utils.c
index 9588a9cd23..cda4ae6354 100644
--- a/src/lxc/string_utils.c
+++ b/src/lxc/string_utils.c
@@ -519,6 +519,7 @@ int lxc_grow_array(void ***array, size_t *capacity, size_t new_size, size_t capa
 	/* first time around, catch some trivial mistakes of the user
 	 * only initializing one of these */
 	if (!*array || !*capacity) {
+		free(*array);
 		*array = NULL;
 		*capacity = 0;
 	}


More information about the lxc-devel mailing list