On Sun, Dec 08, 2013 at 12:55:57PM -0800, Alan Coopersmith wrote:
> Found by cppcheck:
> [app/iceauth/process.c:302]: (error) Common realloc mistake:
>  'argv' nulled but not freed upon failure
> 
> Signed-off-by: Alan Coopersmith <[email protected]>

Reviewed-by: Peter Hutterer <[email protected]>

Cheers,
   Peter

> ---
>  process.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/process.c b/process.c
> index 09cb7ef..6f7396d 100644
> --- a/process.c
> +++ b/process.c
> @@ -298,9 +298,13 @@ static char **split_into_words (  /* argvify string */
>       savec = *src;
>       *src = '\0';
>       if (cur == total) {
> +         char **prevargv = argv;
>           total += WORDSTOALLOC;
>           argv = (char **) realloc (argv, total * sizeof (char *));
> -         if (!argv) return NULL;
> +         if (!argv) {
> +             free (prevargv);
> +             return NULL;
> +         }
>       }
>       argv[cur++] = jword;
>       if (savec) src++;               /* if not last on line advance */
> -- 
> 1.7.9.2
> 
> _______________________________________________
> [email protected]: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to