Re: Potential NULL dereference found in typecmds.c - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Potential NULL dereference found in typecmds.c
Date
Msg-id 4E11BCA3.1080502@enterprisedb.com
Whole thread Raw
In response to Re: Potential NULL dereference found in typecmds.c  (Peter Geoghegan <peter@2ndquadrant.com>)
Responses Re: Potential NULL dereference found in typecmds.c
List pgsql-hackers
On 04.07.2011 16:07, Peter Geoghegan wrote:
> On 4 July 2011 13:53, Magnus Hagander<magnus@hagander.net>  wrote:
>> This code is no longer present in git head, *removed* by commit
>> 426cafc. Not added by it. at least that's how I read the history...
>>
>> However, it still looks to me like we could get to that code with
>> con=NULL - if the while loop is never executed. Perhaps this is a
>> can-never-happen situation? Alvaro?
>
> Seems slightly academic IMHO. No code path should dereference an
> invariably NULL or wild pointer.

That error message is bogus anyway:

>     if (!found)
>         ereport(ERROR,
>                 (errcode(ERRCODE_UNDEFINED_OBJECT),
>                  errmsg("constraint \"%s\" of domain \"%s\" does not exist",
>                         constrName, NameStr(con->conname))));

It passes con->conname as the name of the domain, which is just wrong. 
It should be TypeNameToString(typename) instead. The second error 
message that follows has the same bug.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Potential NULL dereference found in typecmds.c
Next
From: Radoslaw Smogura
Date:
Subject: Re: Crash dumps