[PATCH] top: fix double free causing a SIGABRT storm after SIGPIPE

Denys Vlasenko vda.linux at googlemail.com
Fri Aug 19 18:30:47 UTC 2016


On Fri, Aug 19, 2016 at 8:17 PM, Rob Landley <rob at landley.net> wrote:
> On 08/19/2016 04:10 AM, Denys Vlasenko wrote:
>> +       if (ENABLE_FEATURE_CLEAN_UP) {
>> +               clearmems();
>> +#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
>> +               free(prev_hist);
>> +#endif
>> +       }
>
> The point of the ENABLE macros was so that you can go:
>
>   if (ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE)
>     free(prev_hist);
>
> Instead of the #ifdef forest. #ifdef CONFIG_FEATURE_BLAH already existed...

Indeed ifders are ugly.
In this case, prev_hist does not exist if
!ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE:

rocps/top.c:195:28: error: ‘struct globals’ has no member named ‘prev_hist’
 #define prev_hist        (G.prev_hist         )
                            ^
procps/top.c:1258:9: note: in expansion of macro ‘prev_hist’
    free(prev_hist);
         ^~~~~~~~~


More information about the busybox mailing list