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

Commit7b542cd

Browse files
committed
Fix off-by-one Asserts in FreePageBtreeInsertInternal/Leaf.
These two functions expect there to be room to insert another itemin the FreePageBtree's array, but their assertions were too weakto guarantee that. This has little practical effect granting thatthe callers are not buggy, but it seems to be misleading late-modelCoverity into complaining about possible array overrun.Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/799984.1761150474@sss.pgh.pa.usBackpatch-through: 13
1 parent7fb8c92 commit7b542cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/backend/utils/mmgr/freepage.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,14 @@ FreePageBtreeGetRecycled(FreePageManager *fpm)
894894
}
895895

896896
/*
897-
* Insert an item into an internal page.
897+
* Insert an item into an internal page (there must be room).
898898
*/
899899
staticvoid
900900
FreePageBtreeInsertInternal(char*base,FreePageBtree*btp,Sizeindex,
901901
Sizefirst_page,FreePageBtree*child)
902902
{
903903
Assert(btp->hdr.magic==FREE_PAGE_INTERNAL_MAGIC);
904-
Assert(btp->hdr.nused <=FPM_ITEMS_PER_INTERNAL_PAGE);
904+
Assert(btp->hdr.nused<FPM_ITEMS_PER_INTERNAL_PAGE);
905905
Assert(index <=btp->hdr.nused);
906906
memmove(&btp->u.internal_key[index+1],&btp->u.internal_key[index],
907907
sizeof(FreePageBtreeInternalKey)* (btp->hdr.nused-index));
@@ -911,14 +911,14 @@ FreePageBtreeInsertInternal(char *base, FreePageBtree *btp, Size index,
911911
}
912912

913913
/*
914-
* Insert an item into a leaf page.
914+
* Insert an item into a leaf page (there must be room).
915915
*/
916916
staticvoid
917917
FreePageBtreeInsertLeaf(FreePageBtree*btp,Sizeindex,Sizefirst_page,
918918
Sizenpages)
919919
{
920920
Assert(btp->hdr.magic==FREE_PAGE_LEAF_MAGIC);
921-
Assert(btp->hdr.nused <=FPM_ITEMS_PER_LEAF_PAGE);
921+
Assert(btp->hdr.nused<FPM_ITEMS_PER_LEAF_PAGE);
922922
Assert(index <=btp->hdr.nused);
923923
memmove(&btp->u.leaf_key[index+1],&btp->u.leaf_key[index],
924924
sizeof(FreePageBtreeLeafKey)* (btp->hdr.nused-index));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp