Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitddd96e1

Browse files
committed
Guard against malloc failure. Also, don't examine segP->lastBackend
until we hold the spinlock.
1 parentd8adce8 commitddd96e1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎src/backend/storage/ipc/sinval.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.31 2001/05/18 21:24:20 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.32 2001/06/01 20:07:16 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -283,15 +283,24 @@ GetSnapshotData(bool serializable)
283283
intindex;
284284
intcount=0;
285285

286+
if (snapshot==NULL)
287+
elog(ERROR,"Memory exhausted in GetSnapshotData");
288+
289+
snapshot->xmin=GetCurrentTransactionId();
290+
291+
SpinAcquire(SInvalLock);
292+
286293
/*
287294
* There can be no more than lastBackend active transactions, so this
288295
* is enough space:
289296
*/
290297
snapshot->xip= (TransactionId*)
291298
malloc(segP->lastBackend*sizeof(TransactionId));
292-
snapshot->xmin=GetCurrentTransactionId();
293-
294-
SpinAcquire(SInvalLock);
299+
if (snapshot->xip==NULL)
300+
{
301+
SpinRelease(SInvalLock);
302+
elog(ERROR,"Memory exhausted in GetSnapshotData");
303+
}
295304

296305
/*
297306
* Unfortunately, we have to call ReadNewTransactionId() after

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp