aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2015-04-03 18:29:38 +0900
committerFujii Masao <fujii@postgresql.org>2015-04-03 18:29:38 +0900
commit9b8d4782ba0f75eb0f029c743bb85166999d9fa5 (patch)
treef82c476bf0b8c2b69211aa46ddb1c32a550a8d48
parent8c8a886268dfa616193dadc98e44e0715f884614 (diff)
downloadpostgresql-9b8d4782ba0f75eb0f029c743bb85166999d9fa5.tar.gz
postgresql-9b8d4782ba0f75eb0f029c743bb85166999d9fa5.zip
Rework handling of OOM when allocating record buffer in XLOG reader.
Commit 2c03216 changed allocate_recordbuf() so that it uses a palloc to allocate the read buffer and fails immediately when an out-of-memory error shows up, even though its callers still expect that NULL is returned in that case. This bug is fixed making allocate_recordbuf() use a palloc_extended with MCXT_ALLOC_NO_OOM flag and return NULL in OOM case. Michael Paquier
-rw-r--r--src/backend/access/transam/xlogreader.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index ba7dfcc0287..ffdc9753ad7 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -146,7 +146,13 @@ allocate_recordbuf(XLogReaderState *state, uint32 reclength)
if (state->readRecordBuf)
pfree(state->readRecordBuf);
- state->readRecordBuf = (char *) palloc(newSize);
+ state->readRecordBuf =
+ (char *) palloc_extended(newSize, MCXT_ALLOC_NO_OOM);
+ if (state->readRecordBuf == NULL)
+ {
+ state->readRecordBufSize = 0;
+ return false;
+ }
state->readRecordBufSize = newSize;
return true;
}