]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix oversight in handling of modifiedCols since f24523672d
authorTomas Vondra <tomas.vondra@postgresql.org>
Sun, 2 Jul 2023 18:29:01 +0000 (20:29 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sun, 2 Jul 2023 20:22:50 +0000 (22:22 +0200)
commit7ae4e786892f45af4ded23c94a26537a4b11a4c7
tree2c9ce36559fb8b9e828bf33db460566cf4540b10
parent0c5fe4ff6b2b3daf08676d7939f1d7f3a6235212
Fix oversight in handling of modifiedCols since f24523672d

Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap
into the per-row memory context. In the case of AFTER UPDATE triggers,
the bitmap is however referenced from an event kept until the end of the
query, resulting in a use-after-free bug.

Fixed by copying the bitmap into the AfterTriggerEvents memory context,
which is the one where we keep the trigger events. There's only one
place that needs to do the copy, but the memory context may not exist
yet. Doing that in a separate function seems more readable.

Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the
bitmap was added to the event by commit 71d60e2aa0.

Reported-by: Alexander Pyhalov
Backpatch-through: 13
Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru
src/backend/commands/trigger.c