mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix error handling of XLogReaderAllocate in case of OOM
Similarly to previous fix9b8d478
, commit2c03216
has switched XLogReaderAllocate() to use a set of palloc calls instead of malloc, causing any callers of this function to fail with an error instead of receiving a NULL pointer in case of out-of-memory error. Fix this by using palloc_extended with MCXT_ALLOC_NO_OOM that will safely return NULL in case of an OOM. Michael Paquier, slightly modified by me.
This commit is contained in:
@ -163,6 +163,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();
|
||||
|
Reference in New Issue
Block a user