lo_creat() bug

Started by Gavin Sherryover 24 years ago2 messages
#1Gavin Sherry
swm@linuxworld.com.au

Hi all,

I was just looking through libpq large object code an noticed what seemed
to be a bug. The function lo_create() is declared as Oid yet it contains
the following code:

if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
{
if (lo_initialize(conn) < 0)
return -1;
}

If lo_initialize returns < 0, you have some pretty serious problems - out
of memory, conn is invalid, etc. However, casting -1 to Oid returns what
seems to be a valid Oid. Shouldn't it return InvalidOid?

Gavin

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gavin Sherry (#1)
Re: lo_creat() bug

Gavin Sherry <swm@linuxworld.com.au> writes:

If lo_initialize returns < 0, you have some pretty serious problems - out
of memory, conn is invalid, etc. However, casting -1 to Oid returns what
seems to be a valid Oid. Shouldn't it return InvalidOid?

Yes, evidently so. Good catch!

regards, tom lane