From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Possible dereference null return (src/backend/replication/logical/reorderbuffer.c) |
Date: | 2021-02-10 23:12:38 |
Message-ID: | CAEudQAoxLGtyt3XmOzCi091dpW+o__9DmuE9rmRmDsdyXEpVVA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
Per Coverity.
If xid is a subtransaction, the setup of base snapshot on the top-level
transaction,
can be not optional, otherwise a Dereference null return value
(NULL_RETURNS) can be raised.
Patch suggestion to fix this.
diff --git a/src/backend/replication/logical/reorderbuffer.c
b/src/backend/replication/logical/reorderbuffer.c
index 5a62ab8bbc..3c6a81f716 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2993,8 +2993,8 @@ ReorderBufferSetBaseSnapshot(ReorderBuffer *rb,
TransactionId xid,
*/
txn = ReorderBufferTXNByXid(rb, xid, true, &is_new, lsn, true);
if (rbtxn_is_known_subxact(txn))
- txn = ReorderBufferTXNByXid(rb, txn->toplevel_xid, false,
- NULL, InvalidXLogRecPtr, false);
+ txn = ReorderBufferTXNByXid(rb, txn->toplevel_xid, true,
+ NULL, InvalidXLogRecPtr, true);
Assert(txn->base_snapshot == NULL);
txn->base_snapshot = snap;
regards,
Ranier Vilela
Attachment | Content-Type | Size |
---|---|---|
reorderbuffer.patch | application/octet-stream | 725 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Nancarrow | 2021-02-10 23:24:27 | Re: Parallel INSERT (INTO ... SELECT ...) |
Previous Message | Ranier Vilela | 2021-02-10 22:54:46 | Possible dereference after null check (src/backend/executor/ExecUtils.c) |