aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>2013-10-16 14:43:30 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-10-16 14:43:30 +0200
commit840ef17f63c85044c15d9a38a13c6539e26dfc31 (patch)
tree83c17eefba33cc8c01f9f6e461cc5603e988fd3e
parent5117eff6f938a6daa269f965a52abc93b49d90d6 (diff)
downloadbusybox-840ef17f63c85044c15d9a38a13c6539e26dfc31.tar.gz
wget: if FEATURE_CLEAN_UP, free(ptr_to_globals)
Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h5
-rw-r--r--networking/wget.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 3ab1d6b46..c96546109 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1773,6 +1773,11 @@ extern struct globals *const ptr_to_globals;
(*(struct globals**)&ptr_to_globals) = (void*)(x); \
barrier(); \
} while (0)
+#define FREE_PTR_TO_GLOBALS() do { \
+ if (ENABLE_FEATURE_CLEAN_UP) { \
+ free(ptr_to_globals); \
+ } \
+} while (0)
/* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
* use bb_default_login_shell and following defines.
diff --git a/networking/wget.c b/networking/wget.c
index a32f85229..cfbaceced 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -89,6 +89,9 @@ struct globals {
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
+#define FINI_G() do { \
+ FREE_PTR_TO_GLOBALS(); \
+} while (0)
/* Must match option string! */
@@ -1013,5 +1016,10 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
if (G.output_fd >= 0)
xclose(G.output_fd);
+#if ENABLE_FEATURE_CLEAN_UP && ENABLE_FEATURE_WGET_LONG_OPTIONS
+ free(G.extra_headers);
+#endif
+ FINI_G();
+
return EXIT_SUCCESS;
}