Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ed5b0f7

Browse files
committed
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.
1 parent 83fb1ca commit ed5b0f7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/replication/logical/logical.c

+5
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ StartupDecodingContext(List *output_plugin_options,
162162
ctx->slot = slot;
163163

164164
ctx->reader = XLogReaderAllocate(read_page, ctx);
165+
if (!ctx->reader)
166+
ereport(ERROR,
167+
(errcode(ERRCODE_OUT_OF_MEMORY),
168+
errmsg("out of memory")));
169+
165170
ctx->reader->private_data = ctx;
166171

167172
ctx->reorder = ReorderBufferAllocate();

0 commit comments

Comments
 (0)