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

Commit4bfc5f1

Browse files
committed
Fix off-by-one bug in LWLockRegisterTranche().
Original coding failed to enlarge the array as required ifthe requested tranche_id was equal to LWLockTranchesAllocated.In passing, fix poor style of not casting the result of (re)palloc.
1 parent49137ec commit4bfc5f1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ CreateLWLocks(void)
350350
if (LWLockTrancheArray==NULL)
351351
{
352352
LWLockTranchesAllocated=16;
353-
LWLockTrancheArray=MemoryContextAlloc(TopMemoryContext,
354-
LWLockTranchesAllocated*sizeof(LWLockTranche*));
353+
LWLockTrancheArray= (LWLockTranche**)
354+
MemoryContextAlloc(TopMemoryContext,
355+
LWLockTranchesAllocated*sizeof(LWLockTranche*));
355356
}
356357

357358
MainLWLockTranche.name="main";
@@ -423,11 +424,12 @@ LWLockRegisterTranche(int tranche_id, LWLockTranche *tranche)
423424
{
424425
inti=LWLockTranchesAllocated;
425426

426-
while (i<tranche_id)
427+
while (i <=tranche_id)
427428
i *=2;
428429

429-
LWLockTrancheArray=repalloc(LWLockTrancheArray,
430-
i*sizeof(LWLockTranche*));
430+
LWLockTrancheArray= (LWLockTranche**)
431+
repalloc(LWLockTrancheArray,
432+
i*sizeof(LWLockTranche*));
431433
LWLockTranchesAllocated=i;
432434
}
433435

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp