On 04/15/2014 10:06 PM, Bernhard Voelker wrote:
> * src/df.c (alloc_table_row): Use the size of char** to enlarge
> the table.  Spotted by Coverity.
> ---
>  src/df.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/df.c b/src/df.c
> index 3036c74..e763943 100644
> --- a/src/df.c
> +++ b/src/df.c
> @@ -290,7 +290,7 @@ static void
>  alloc_table_row (void)
>  {
>    nrows++;
> -  table = xnrealloc (table, nrows, sizeof (char *));
> +  table = xnrealloc (table, nrows, sizeof (char **));
>    table[nrows - 1] = xnmalloc (ncolumns, sizeof (char *));
>  }

So coverity says:

  CID 1191815 (#1 of 1): Wrong sizeof argument (SIZEOF_MISMATCH)
  suspicious_sizeof: Passing argument 8UL /* sizeof (char *) */ to function 
xnrealloc
  and then casting the return value to char *** is suspicious

The patch is good to get rid of the warning, but we're
just dealing with pointers here so there is no change to the code.
Hence I'd change the commit message to:

  maint: df: avoid sizeof(char**) static analysis warning

thanks!
Pádraig.

Reply via email to