1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-24 14:22:24 +03:00

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.
This commit is contained in:
Andres Freund
2015-01-08 13:35:04 +01:00
parent 83fb1ca5cf
commit ed5b0f7951

View File

@ -162,6 +162,11 @@ StartupDecodingContext(List *output_plugin_options,
ctx->slot = slot; ctx->slot = slot;
ctx->reader = XLogReaderAllocate(read_page, ctx); 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->reader->private_data = ctx;
ctx->reorder = ReorderBufferAllocate(); ctx->reorder = ReorderBufferAllocate();