From: Tom Lane Date: Sun, 10 Feb 2008 20:39:08 +0000 (+0000) Subject: Fix PageGetExactFreeSpace() so that it actually behaves sensibly X-Git-Tag: REL8_3_1~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=082aca9ec2854f8e25730c37411685f51a6277de;p=thirdparty%2Fpostgresql.git Fix PageGetExactFreeSpace() so that it actually behaves sensibly if pd_lower > pd_upper, rather than merely claiming to. This would only matter if the page header were corrupt, which shouldn't occur, but ... --- diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 32b80c182f0..ad1c8c3ed3f 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.77 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.78 2008/02/10 20:39:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -489,6 +489,9 @@ PageGetExactFreeSpace(Page page) space = (int) ((PageHeader) page)->pd_upper - (int) ((PageHeader) page)->pd_lower; + if (space < 0) + return 0; + return (Size) space; }