Re: [BUG FIX] Uninitialized var fargtypes used.

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ranier Vilela <ranier_gyn@hotmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-11-11T17:32:38Z
Lists: pgsql-bugs
Ranier Vilela <ranier_gyn@hotmail.com> writes:
> Can anyone check this bug fix?

> -	Oid			fargtypes[1];	/* dummy */
> +	Oid			fargtypes[1] = {InvalidOid, InvalidOid};	/* dummy */

Well, it's wrong on its face, because that array only has one element
not two.  But why do you care?  The element will never be accessed.

The only reason we declare this variable at all is that LookupFuncName
requires a non-null pointer, which if memory serves is because memcmp()
with a null pointer is formally undefined even if the count is zero,
cf commit 0a52d378b.

Maybe it would've been better to make LookupFuncName deal with the
case instead of requiring callers to do strange things.  But I don't
see any bug here.

			regards, tom lane



Commits

  1. Finish reverting commit 0a52d378b.

  2. Have LookupFuncName accept NULL argtypes for 0 args

  3. Avoid passing NULL to memcmp() in lookups of zero-argument functions.