]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix use-after-free bug with AfterTriggersTableData.storeslot
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 27 Feb 2021 21:09:15 +0000 (18:09 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 27 Feb 2021 21:09:15 +0000 (18:09 -0300)
commit262eb990c72097bd804e5c747fe38bf9b3a1ded9
tree1ff2e93f76138db6015c62fe7e7535da37d016a5
parentfb1e218cb07e9b78a26d52d1c7fc03f5ce8691eb
Fix use-after-free bug with AfterTriggersTableData.storeslot

AfterTriggerSaveEvent() wrongly allocates the slot in execution-span
memory context, whereas the correct thing is to allocate it in
a transaction-span context, because that's where the enclosing
AfterTriggersTableData instance belongs into.

Backpatch to 12 (the test back to 11, where it works well with no code
changes, and it's good to have to confirm that the case was previously
well supported); this bug seems introduced by commit ff11e7f4b9ae.

Reported-by: Bertrand Drouvot <bdrouvot@amazon.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/39a71864-b120-5a5c-8cc5-c632b6f16761@amazon.com
src/backend/commands/trigger.c
src/test/regress/expected/triggers.out
src/test/regress/sql/triggers.sql