Skip to content

Commit

Permalink
Check for a null proc_src before calling get_func_arg_info
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jun 25, 2010
1 parent 60962c5 commit f03ace1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plparrot.c
Expand Up @@ -198,13 +198,16 @@ plperl6_func_handler(PG_FUNCTION_ARGS)
proctup = SearchSysCache(PROCOID, ObjectIdGetDatum(fcinfo->flinfo->fn_oid), 0, 0, 0);
if (!HeapTupleIsValid(proctup))
elog(ERROR, "Failed to look up procedure with OID %u", fcinfo->flinfo->fn_oid);

procstruct = (Form_pg_proc) GETSTRUCT(proctup);
returntype = procstruct->prorettype;
procsrc_datum = SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosrc, &isnull);
numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes);

if (isnull)
elog(ERROR, "Couldn't load function source for function with OID %u", fcinfo->flinfo->fn_oid);

numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes);

ReleaseSysCache(proctup);
proc_src = TextDatum2String(procsrc_datum);
length = strlen(proc_src);
Expand Down Expand Up @@ -271,11 +274,12 @@ plparrot_func_handler(PG_FUNCTION_ARGS)
procstruct = (Form_pg_proc) GETSTRUCT(proctup);
returntype = procstruct->prorettype;
procsrc_datum = SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosrc, &isnull);
numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes);

if (isnull)
elog(ERROR, "Couldn't load function source for function with OID %u", fcinfo->flinfo->fn_oid);

numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes);

/* procstruct probably isn't valid after this ReleaseSysCache call, so don't use it anymore */
ReleaseSysCache(proctup);
proc_src = TextDatum2String(procsrc_datum);
Expand Down

0 comments on commit f03ace1

Please sign in to comment.