]> granicus.if.org Git - postgresql/commit
Avoid passing NULL to memcmp() in lookups of zero-argument functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 27 Jun 2015 21:47:39 +0000 (17:47 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 27 Jun 2015 21:47:39 +0000 (17:47 -0400)
commit0a52d378b03b7d5ab1d64627a87edaf5ed311c6c
tree3fcd6572bb27480117b97cf1b70ed9e4f9c4f27c
parentd47a1136e441cebe7ae7fe72d70eb8ce278d5cd6
Avoid passing NULL to memcmp() in lookups of zero-argument functions.

A few places assumed they could pass NULL for the argtypes array when
looking up functions known to have zero arguments.  At first glance
it seems that this should be safe enough, since memcmp() is surely not
allowed to fetch any bytes if its count argument is zero.  However,
close reading of the C standard says that such calls have undefined
behavior, so we'd probably best avoid it.

Since the number of places doing this is quite small, and some other
places looking up zero-argument functions were already passing dummy
arrays, let's standardize on the latter solution rather than hacking
the function lookup code to avoid calling memcmp() in these cases.
I also added Asserts to catch any future violations of the new rule.

Given the utter lack of any evidence that this actually causes any
problems in the field, I don't feel a need to back-patch this change.

Per report from Piotr Stefaniak, though this is not his patch.
src/backend/commands/event_trigger.c
src/backend/commands/foreigncmds.c
src/backend/parser/parse_func.c
src/backend/utils/adt/ruleutils.c