projects
/
openwrt
/
staging
/
nbd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2dca717
)
packages: nvram: fix memory leak in _nvram_free
author
Zhai Zhaoxuan
<zhaizhaoxuan@xiaomi.com>
Tue, 11 Jul 2017 10:12:00 +0000
(18:12 +0800)
committer
John Crispin
<john@phrozen.org>
Wed, 15 Nov 2017 20:11:23 +0000
(21:11 +0100)
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>
package/utils/nvram/src/nvram.c
patch
|
blob
|
history
diff --git
a/package/utils/nvram/src/nvram.c
b/package/utils/nvram/src/nvram.c
index ca893921076ee17db3e855138f91c28a87d2d1c4..d5e12ee69a3e78cc94916c75009444795d8c1baf 100644
(file)
--- 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);
}