aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-06-01 20:07:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-06-01 20:07:16 +0000
commitddd96e1f211285e8561c673cad137ae10ea19d85 (patch)
treeb230cc69f05b3de2fce34ad4f784709e05b8fef0 /src
parentd8adce898314b44312b9a9f625e2a7cb3ed42600 (diff)
downloadpostgresql-ddd96e1f211285e8561c673cad137ae10ea19d85.tar.gz
postgresql-ddd96e1f211285e8561c673cad137ae10ea19d85.zip
Guard against malloc failure. Also, don't examine segP->lastBackend
until we hold the spinlock.
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/ipc/sinval.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index f39b8f8c648..d60e6198f51 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.31 2001/05/18 21:24:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.32 2001/06/01 20:07:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -283,15 +283,24 @@ GetSnapshotData(bool serializable)
int index;
int count = 0;
+ if (snapshot == NULL)
+ elog(ERROR, "Memory exhausted in GetSnapshotData");
+
+ snapshot->xmin = GetCurrentTransactionId();
+
+ SpinAcquire(SInvalLock);
+
/*
* There can be no more than lastBackend active transactions, so this
* is enough space:
*/
snapshot->xip = (TransactionId *)
malloc(segP->lastBackend * sizeof(TransactionId));
- snapshot->xmin = GetCurrentTransactionId();
-
- SpinAcquire(SInvalLock);
+ if (snapshot->xip == NULL)
+ {
+ SpinRelease(SInvalLock);
+ elog(ERROR, "Memory exhausted in GetSnapshotData");
+ }
/*
* Unfortunately, we have to call ReadNewTransactionId() after