Skip to content

Commit

Permalink
Plug a memory leak in plparrot_make_sausage
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Apr 11, 2010
1 parent 988f885 commit 74d4089
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plparrot.c
Expand Up @@ -300,9 +300,8 @@ perm_fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum
plparrot_make_sausage(Parrot_Interp interp, Parrot_PMC pmc, FunctionCallInfo fcinfo)
{
char *str;
char *str, *pgstr;
plparrot_proc_desc *prodesc;
Parrot_String s;
HeapTuple procTup, typeTup;
Form_pg_proc procStruct;
Form_pg_type typeStruct;
Expand All @@ -311,10 +310,9 @@ plparrot_make_sausage(Parrot_Interp interp, Parrot_PMC pmc, FunctionCallInfo fci
if (Parrot_PMC_isa(interp,pmc,create_string("Integer"))) {
return Int32GetDatum(Parrot_PMC_get_integer(interp,pmc));
} else if (Parrot_PMC_isa(interp,pmc,create_string("String"))) {
/* XXX: This kind of works */
s = Parrot_PMC_get_string(interp,pmc);
str = Parrot_str_to_cstring(interp,s);
/* elog(NOTICE,"sausage string = %s", str); */
str = Parrot_str_to_cstring(interp, Parrot_PMC_get_string(interp,pmc));
pgstr = pstrdup(str);
Parrot_str_free_cstring(str);

procTup = SearchSysCache(PROCOID, ObjectIdGetDatum(fcinfo->flinfo->fn_oid), 0, 0, 0);
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
Expand All @@ -334,7 +332,7 @@ plparrot_make_sausage(Parrot_Interp interp, Parrot_PMC pmc, FunctionCallInfo fci
ReleaseSysCache(typeTup);
ReleaseSysCache(procTup);

return InputFunctionCall(&prodesc->result_in_func, str, prodesc->result_typioparam, -1);
return InputFunctionCall(&prodesc->result_in_func, pgstr, prodesc->result_typioparam, -1);

} else if (Parrot_PMC_isa(interp,pmc,create_string("Float"))) {
return Float8GetDatum(Parrot_PMC_get_number(interp,pmc));
Expand Down

0 comments on commit 74d4089

Please sign in to comment.