Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit41c742a

Browse files
committed
Fix use-after-free bug with event triggers and ALTER TABLE.
EventTriggerAlterTableEnd neglected to make sure that it built itsoutput list in the right context. In simple cases this was maskedbecause the function is called in PortalContext which will besufficiently long-lived anyway; but that doesn't make it not a bug.Commitced138e fixed this in HEAD and v13, but mistakenly chosenot to back-patch further. Back-patch the same code change allthe way (I didn't bother with the test case though, as it wouldprove nothing in pre-v13 branches).Per report from Arseny Sher.Original fix by Jehan-Guillaume de Rorthais.Discussion:https://postgr.es/m/877drcyprb.fsf@ars-thinkpadDiscussion:https://postgr.es/m/20200902193715.6e0269d4@firost
1 parent38e4b15 commit41c742a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎src/backend/commands/event_trigger.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,9 +1828,15 @@ EventTriggerAlterTableEnd(void)
18281828
/* If no subcommands, don't collect */
18291829
if (list_length(currentEventTriggerState->currentCommand->d.alterTable.subcmds)!=0)
18301830
{
1831+
MemoryContextoldcxt;
1832+
1833+
oldcxt=MemoryContextSwitchTo(currentEventTriggerState->cxt);
1834+
18311835
currentEventTriggerState->commandList=
18321836
lappend(currentEventTriggerState->commandList,
18331837
currentEventTriggerState->currentCommand);
1838+
1839+
MemoryContextSwitchTo(oldcxt);
18341840
}
18351841
else
18361842
pfree(currentEventTriggerState->currentCommand);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp