Re: [Powertop] [PATCH] prevent jump on uninitialized value

Chris Ferron <chris.e.ferron at linux.intel.com> Wed, 27 Jun 2012 11:20:00 -0700
Newsgroups dev.linux.lists.powertop
Message-ID <[email protected]>
patch applied
Thanks
-C

On 06/27/2012 01:17 AM, Sergey Senozhatsky wrote:
> workload is getting 'initialized' with stack garbage,
> so later conditional check of !workload[0] in report()
> is invalid.
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
>
> ---
>
>   src/main.cpp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/main.cpp b/src/main.cpp
> index d8e2a47..7a1b976 100644
> --- a/src/main.cpp
> +++ b/src/main.cpp
> @@ -356,7 +356,7 @@ int main(int argc, char **argv)
>   	int c;
>   	bool wantreport = FALSE;
>   	char filename[4096];
> -	char workload[4096];
> +	char workload[4096] = {0,};
>   	int  iterations = 1;
>   
>   #ifndef DISABLE_TRYCATCH
>