Skip to content

Commit 112caf9

Browse files
committed
Finish reverting commit 0a52d37.
Apply the solution adopted in commit dcb7d3c (ie, explicitly don't call memcmp for a zero-length comparison) to func_get_detail() as well, removing one other place where we were passing an uninitialized array to a parse_func.c entry point. Discussion: https://postgr.es/m/MN2PR18MB2927F24692485D754794F01BE3740@MN2PR18MB2927.namprd18.prod.outlook.com Discussion: https://postgr.es/m/MN2PR18MB2927F6873DF2774A505AC298E3740@MN2PR18MB2927.namprd18.prod.outlook.com
1 parent c5e8ea9 commit 112caf9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/backend/parser/parse_func.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -1397,9 +1397,6 @@ func_get_detail(List *funcname,
13971397
FuncCandidateList raw_candidates;
13981398
FuncCandidateList best_candidate;
13991399

1400-
/* Passing NULL for argtypes is no longer allowed */
1401-
Assert(argtypes);
1402-
14031400
/* initialize output arguments to silence compiler warnings */
14041401
*funcid = InvalidOid;
14051402
*rettype = InvalidOid;
@@ -1423,7 +1420,9 @@ func_get_detail(List *funcname,
14231420
best_candidate != NULL;
14241421
best_candidate = best_candidate->next)
14251422
{
1426-
if (memcmp(argtypes, best_candidate->args, nargs * sizeof(Oid)) == 0)
1423+
/* if nargs==0, argtypes can be null; don't pass that to memcmp */
1424+
if (nargs == 0 ||
1425+
memcmp(argtypes, best_candidate->args, nargs * sizeof(Oid)) == 0)
14271426
break;
14281427
}
14291428

src/backend/utils/adt/ruleutils.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
833833
char *tgname;
834834
char *tgoldtable;
835835
char *tgnewtable;
836-
Oid argtypes[1]; /* dummy */
837836
Datum value;
838837
bool isnull;
839838

@@ -1045,7 +1044,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
10451044

10461045
appendStringInfo(&buf, "EXECUTE FUNCTION %s(",
10471046
generate_function_name(trigrec->tgfoid, 0,
1048-
NIL, argtypes,
1047+
NIL, NULL,
10491048
false, NULL, EXPR_KIND_NONE));
10501049

10511050
if (trigrec->tgnargs > 0)

0 commit comments

Comments
 (0)