summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-01-08 13:35:04 +0100
committerAndres Freund <andres@anarazel.de>2015-01-08 13:35:04 +0100
commited5b0f79512aa37fc92d2097bc9a0b93a27eaee2 (patch)
tree62b80d361d04c673f55dd759394a269c2cab413c /src
parent83fb1ca5cf393f3a12930bd9275a711cd858c823 (diff)
Protect against XLogReaderAllocate() failing to allocate memory.
logical.c's StartupDecodingContext() forgot to check whether XLogReaderAllocate() returns NULL indicating a memory allocation failure. This could lead, although quite unlikely, lead to a NULL pointer dereference. This only applies to 9.4 as earlier versions don't do logical decoding, and later versions don't return NULL after allocation failures in XLogReaderAllocate(). Michael Paquier, with minor changes by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/logical/logical.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 80b61020bec..156c4181ecc 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -162,6 +162,11 @@ StartupDecodingContext(List *output_plugin_options,
ctx->slot = slot;
ctx->reader = XLogReaderAllocate(read_page, ctx);
+ if (!ctx->reader)
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
+
ctx->reader->private_data = ctx;
ctx->reorder = ReorderBufferAllocate();