mirror of https://github.com/citusdata/citus.git
Fix use-after-free in GetAlterTriggerStateCommand() (#6413)
Fix use-after-free in GetAlterTriggerStateCommand() introduced in #6398.pull/6418/head
parent
1776bdf654
commit
517b72a9d5
|
@ -139,8 +139,6 @@ GetAlterTriggerStateCommand(Oid triggerId)
|
|||
const char *quotedTrigName = quote_identifier(NameStr(triggerForm->tgname));
|
||||
char enableDisableState = triggerForm->tgenabled;
|
||||
|
||||
heap_freetuple(triggerTuple);
|
||||
|
||||
const char *alterTriggerStateStr = NULL;
|
||||
switch (enableDisableState)
|
||||
{
|
||||
|
@ -178,6 +176,13 @@ GetAlterTriggerStateCommand(Oid triggerId)
|
|||
appendStringInfo(alterTriggerStateCommand, "ALTER TABLE %s %s TRIGGER %s;",
|
||||
qualifiedRelName, alterTriggerStateStr, quotedTrigName);
|
||||
|
||||
/*
|
||||
* Free triggerTuple at the end since quote_identifier() might not return
|
||||
* a palloc'd string if given identifier doesn't need to be quoted, and in
|
||||
* that case quotedTrigName would still be bound to triggerTuple.
|
||||
*/
|
||||
heap_freetuple(triggerTuple);
|
||||
|
||||
return alterTriggerStateCommand->data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue