aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhai Zhaoxuan <zhaizhaoxuan@xiaomi.com>2017-07-11 18:12:00 +0800
committerJo-Philipp Wich <jo@mein.io>2017-12-13 16:51:59 +0100
commit06258144266a5adb44d2ef072c2a7c051584a24d (patch)
tree9af1e1c310808da027d5639fe768b628c7bb1f0f
parent0f175041ad03d381a575e2c2b1a1c9ca76fe0e99 (diff)
downloadupstream-06258144266a5adb44d2ef072c2a7c051584a24d.tar.gz
upstream-06258144266a5adb44d2ef072c2a7c051584a24d.tar.bz2
upstream-06258144266a5adb44d2ef072c2a7c051584a24d.zip
packages: nvram: fix memory leak in _nvram_free
The value of nvram_tuple_t is allocated in _nvram_realloc, but it is not freed in _nvram_free. Signed-off-by: Zhai Zhaoxuan <zhaizhaoxuan@xiaomi.com> (cherry picked from commit c382237ac33a787043b22abc42f0c5a80278baae)
-rw-r--r--package/utils/nvram/src/nvram.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/package/utils/nvram/src/nvram.c b/package/utils/nvram/src/nvram.c
index ca89392107..d5e12ee69a 100644
--- a/package/utils/nvram/src/nvram.c
+++ b/package/utils/nvram/src/nvram.c
@@ -47,6 +47,8 @@ static void _nvram_free(nvram_handle_t *h)
for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
for (t = h->nvram_hash[i]; t; t = next) {
next = t->next;
+ if (t->value)
+ free(t->value);
free(t);
}
h->nvram_hash[i] = NULL;
@@ -55,6 +57,8 @@ static void _nvram_free(nvram_handle_t *h)
/* Free dead table */
for (t = h->nvram_dead; t; t = next) {
next = t->next;
+ if (t->value)
+ free(t->value);
free(t);
}