[PATCH] Avoid dereference null relation pointer (src/backend/replication/logical/reorderbuffer.c)
Started by Ranier Vilelaalmost 4 years ago1 messages
Hi hackers,
Minor oversight with commit 0da92dc
<https://github.com/postgres/postgres/commit/0da92dc530c9251735fc70b20cd004d9630a1266>
.
RelationIdGetRelation can return NULL, then it is necessary to check the
return.
regards,
Ranier Vilela
Attachments:
0001-avoid-dereference-null-relation.patchapplication/octet-stream; name=0001-avoid-dereference-null-relation.patchDownload
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fa..d03d6c5600 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -1110,6 +1110,12 @@ ReorderBufferQueueSequence(ReorderBuffer *rb, TransactionId xid,
MAIN_FORKNUM));
relation = RelationIdGetRelation(reloid);
+ if (!RelationIsValid(relation))
+ elog(ERROR, "could not open relation with OID %u (for filenode \"%s\")",
+ reloid,
+ relpathperm(rnode,
+ MAIN_FORKNUM));
+
tuple = &tuplebuf->tuple;
seq = (Form_pg_sequence_data) GETSTRUCT(tuple);