projects
/
openwrt
/
openwrt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nvram: fix memory leak
[openwrt/openwrt.git]
/
package
/
utils
/
nvram
/
src
/
cli.c
diff --git
a/package/utils/nvram/src/cli.c
b/package/utils/nvram/src/cli.c
index 66ef904885854894b3d9dda6b40a1bd3e5c832f2..4f9c77804d793df4839fdd650f37f09fe9ee21fa 100644
(file)
--- a/
package/utils/nvram/src/cli.c
+++ b/
package/utils/nvram/src/cli.c
@@
-27,13
+27,17
@@
static nvram_handle_t * nvram_open_rdonly(void)
{
static nvram_handle_t * nvram_open_rdonly(void)
{
- c
onst c
har *file = nvram_find_staging();
+ char *file = nvram_find_staging();
if( file == NULL )
file = nvram_find_mtd();
if( file == NULL )
file = nvram_find_mtd();
- if( file != NULL )
- return nvram_open(file, NVRAM_RO);
+ if( file != NULL ) {
+ nvram_handle_t *h = nvram_open(file, NVRAM_RO);
+ if( strcmp(file, NVRAM_STAGING) )
+ free(file);
+ return h;
+ }
return NULL;
}
return NULL;
}
@@
-123,8
+127,8
@@
static int do_info(nvram_handle_t *nvram)
printf("NCDL values: 0x%08X\n\n", hdr->config_ncdl);
printf("%i bytes used / %i bytes available (%.2f%%)\n",
printf("NCDL values: 0x%08X\n\n", hdr->config_ncdl);
printf("%i bytes used / %i bytes available (%.2f%%)\n",
- hdr->len,
NVRAM_SPACE
- hdr->len,
- (100.00 / (double)
NVRAM_SPACE
) * (double)hdr->len);
+ hdr->len,
nvram->length - nvram->offset
- hdr->len,
+ (100.00 / (double)
(nvram->length - nvram->offset)
) * (double)hdr->len);
return 0;
}
return 0;
}