Skip to content

Commit ec76265

Browse files
committed
Don't leak the temporary PLyProcedure struct we create for inline plpython
blocks. Investigation by Jan Urbański, though I didn't use his patch.
1 parent 647f8b3 commit ec76265

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/pl/plpython/plpython.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ plpython_inline_handler(PG_FUNCTION_ARGS)
592592
FunctionCallInfoData fake_fcinfo;
593593
FmgrInfo flinfo;
594594
PLyProcedure *save_curr_proc;
595-
PLyProcedure *volatile proc = NULL;
595+
PLyProcedure proc;
596596
ErrorContextCallback plerrcontext;
597597

598598
if (SPI_connect() != SPI_OK_CONNECT)
@@ -613,26 +613,26 @@ plpython_inline_handler(PG_FUNCTION_ARGS)
613613
flinfo.fn_oid = InvalidOid;
614614
flinfo.fn_mcxt = CurrentMemoryContext;
615615

616-
proc = PLy_malloc0(sizeof(PLyProcedure));
617-
proc->pyname = PLy_strdup("__plpython_inline_block");
618-
proc->result.out.d.typoid = VOIDOID;
616+
MemSet(&proc, 0, sizeof(PLyProcedure));
617+
proc.pyname = PLy_strdup("__plpython_inline_block");
618+
proc.result.out.d.typoid = VOIDOID;
619619

620620
PG_TRY();
621621
{
622-
PLy_procedure_compile(proc, codeblock->source_text);
623-
PLy_curr_procedure = proc;
624-
PLy_function_handler(&fake_fcinfo, proc);
622+
PLy_procedure_compile(&proc, codeblock->source_text);
623+
PLy_curr_procedure = &proc;
624+
PLy_function_handler(&fake_fcinfo, &proc);
625625
}
626626
PG_CATCH();
627627
{
628-
PLy_procedure_delete(proc);
628+
PLy_procedure_delete(&proc);
629629
PLy_curr_procedure = save_curr_proc;
630630
PyErr_Clear();
631631
PG_RE_THROW();
632632
}
633633
PG_END_TRY();
634634

635-
PLy_procedure_delete(proc);
635+
PLy_procedure_delete(&proc);
636636

637637
/* Pop the error context stack */
638638
error_context_stack = plerrcontext.previous;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy