Fix assertion on dereferenced object
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 14 Feb 2025 10:50:56 +0000 (11:50 +0100)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 14 Feb 2025 10:50:56 +0000 (11:50 +0100)
Commit 27cc7cd2bc8a accidentally placed the assertion ensuring
that the pointer isn't NULL after it had already been accessed.
Fix by moving the pointer dereferencing to after the assertion.
Backpatch to all supported branches.

Author: Dmitry Koval <d.koval@postgrespro.ru>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/1618848d-cdc7-414b-9c03-08cf4bef4408@postgrespro.ru
Backpatch-through: 13

src/backend/executor/execMain.c

index 527e914ce965967ade459d3ee774d8cf73a7a283..8048b810e51e59b6800eee76fa7cfeed46b7706b 100644 (file)
@@ -2629,13 +2629,15 @@ bool
 EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot)
 {
    ExecAuxRowMark *earm = epqstate->relsubs_rowmark[rti - 1];
-   ExecRowMark *erm = earm->rowmark;
+   ExecRowMark *erm;
    Datum       datum;
    bool        isNull;
 
    Assert(earm != NULL);
    Assert(epqstate->origslot != NULL);
 
+   erm = earm->rowmark;
+
    if (RowMarkRequiresRowShareLock(erm->markType))
        elog(ERROR, "EvalPlanQual doesn't support locking rowmarks");