diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-08-19 11:07:31 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-08-19 11:07:31 +0200 |
commit | aedc3fe19fac368dc363050e0387d263b7e01cc6 (patch) | |
tree | d72598a6c9d97ed1865d0f0ddc8ca9dc5c202c9b | |
parent | b11be131b73fd47e12b1a9f1c52ac0a1ed222aee (diff) | |
download | busybox-w32-aedc3fe19fac368dc363050e0387d263b7e01cc6.tar.gz busybox-w32-aedc3fe19fac368dc363050e0387d263b7e01cc6.tar.bz2 busybox-w32-aedc3fe19fac368dc363050e0387d263b7e01cc6.zip |
top: move free(prev_hist) out of signal path
It was seen being called recursively on repeated signals,
leading to double free
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/top.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/procps/top.c b/procps/top.c index 73cd285f0..6f7f7d382 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -728,12 +728,6 @@ static void reset_term(void) | |||
728 | { | 728 | { |
729 | if (!OPT_BATCH_MODE) | 729 | if (!OPT_BATCH_MODE) |
730 | tcsetattr_stdin_TCSANOW(&initial_settings); | 730 | tcsetattr_stdin_TCSANOW(&initial_settings); |
731 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
732 | clearmems(); | ||
733 | # if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | ||
734 | free(prev_hist); | ||
735 | # endif | ||
736 | } | ||
737 | } | 731 | } |
738 | 732 | ||
739 | static void sig_catcher(int sig) | 733 | static void sig_catcher(int sig) |
@@ -1258,5 +1252,11 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1258 | #if ENABLE_FEATURE_USE_TERMIOS | 1252 | #if ENABLE_FEATURE_USE_TERMIOS |
1259 | reset_term(); | 1253 | reset_term(); |
1260 | #endif | 1254 | #endif |
1255 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
1256 | clearmems(); | ||
1257 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | ||
1258 | free(prev_hist); | ||
1259 | #endif | ||
1260 | } | ||
1261 | return EXIT_SUCCESS; | 1261 | return EXIT_SUCCESS; |
1262 | } | 1262 | } |