Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 302ac7f

Browse files
committed
Add assertion to check the special size is sane before dereferencing it.
This seems useful to catch errors of the sort I just fixed, where PageGetSpecialPointer is called before initializing the page.
1 parent fdf2885 commit 302ac7f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/include/storage/bufpage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ typedef PageHeaderData *PageHeader;
304304
#define PageGetSpecialPointer(page) \
305305
( \
306306
AssertMacro(PageIsValid(page)), \
307+
AssertMacro(((PageHeader) (page))->pd_special <= BLCKSZ), \
308+
AssertMacro(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData), \
307309
(char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \
308310
)
309311

0 commit comments

Comments
 (0)