Re: small fix to possible null pointer dereference in byteaout() varlena.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: small fix to possible null pointer dereference in byteaout() varlena.c
Date
Msg-id 24913.1285687415@sss.pgh.pa.us
Whole thread Raw
In response to Re: small fix to possible null pointer dereference in byteaout() varlena.c  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
List pgsql-hackers
Grzegorz Jaśkiewicz <gryzman@gmail.com> writes:
> ...
>                 rp = result = NULL;             /* keep compiler quiet */
>         }
>         *rp = '\0';
> ....

> this strikes me as a clear case of possible null pointer dereference,
> wouldn't you agree ?

No, I wouldn't.  You need to enlarge your peephole by one line:
   else   {       elog(ERROR, "unrecognized bytea_output setting: %d",            bytea_output);       rp = result =
NULL;       /* keep compiler quiet */   }   *rp = '\0';
 

The "keep compiler quiet" line is unreachable code (and that comment is
supposed to remind you of that).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: security label support, revised
Next
From: Robert Haas
Date:
Subject: Re: small fix to possible null pointer dereference in byteaout() varlena.c