From: drh <> Date: Wed, 15 Sep 2021 19:13:24 +0000 (+0000) Subject: Add more ALWAYS() macros on unreachable branches in rtree.c X-Git-Tag: version-3.37.0~231^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=750f2331c4322413fb0832748765b164b8844a77;p=thirdparty%2Fsqlite.git Add more ALWAYS() macros on unreachable branches in rtree.c FossilOrigin-Name: fbba89dac9591c56da81bd0808910fbc64640f3ccfd95845ecab4d3aea46ca61 --- diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 5a2062d562..2a054b961d 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2239,12 +2239,19 @@ static int AdjustTree( ){ RtreeNode *p = pNode; int cnt = 0; + int rc; while( p->pParent ){ RtreeNode *pParent = p->pParent; RtreeCell cell; int iCell; - if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell) ){ + cnt++; + if( NEVER(cnt>100) ){ + RTREE_IS_CORRUPT(pRtree); + return SQLITE_CORRUPT_VTAB; + } + rc = nodeParentIndex(pRtree, p, &iCell); + if( NEVER(rc!=SQLITE_OK) ){ RTREE_IS_CORRUPT(pRtree); return SQLITE_CORRUPT_VTAB; } @@ -2628,11 +2635,12 @@ static int SplitNode( RtreeNode *pParent = pLeft->pParent; int iCell; rc = nodeParentIndex(pRtree, pLeft, &iCell); - if( rc==SQLITE_OK ){ + if( ALWAYS(rc==SQLITE_OK) ){ nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); rc = AdjustTree(pRtree, pParent, &leftbbox); + assert( rc==SQLITE_OK ); } - if( rc!=SQLITE_OK ){ + if( NEVER(rc!=SQLITE_OK) ){ goto splitnode_out; } } @@ -2707,8 +2715,9 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){ */ iNode = sqlite3_column_int64(pRtree->pReadParent, 0); for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent); - if( !pTest ){ + if( ALWAYS(pTest==0) ){ rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent); + assert( rc2==SQLITE_OK ); } } rc = sqlite3_reset(pRtree->pReadParent); diff --git a/manifest b/manifest index 6454e97831..38c31dcfa4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sxBestIndex\smethod\son\srtree\sso\sthat\sit\scorrectly\srecognizes\sthat\nrowid=?\sworks\sthe\ssame\sas\sid=?. -D 2021-09-15T16:20:15.282 +C Add\smore\sALWAYS()\smacros\son\sunreachable\sbranches\sin\srtree.c +D 2021-09-15T19:13:24.273 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -393,7 +393,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/geopoly.c 98d45533989e908bf65b43f36ff6eaad95a9ffe6f3b6b8658fbd47d45c58b10b -F ext/rtree/rtree.c 28e41882843e1e8702e29c83c5cc94a6e5bf40c1046623922f4cd743740efcc9 +F ext/rtree/rtree.c d106f223d23401ec353531de2429b41e6bc9dfba85049d2bd4dec0e0f44316b3 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 00792b030a4e188ff1b22e8530e8aa0452bb5dd81c2b18cb004afc7dc63e040e F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -1923,7 +1923,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9123f680ae3100f4c781ac4f5b8afac49bb5d4231b5931ad112b1b615f22f613 -R aa32b780c45fbdfaa5c4a0c43e497966 +P c74c07cc86443057d34284ae31eb68470741592b0e61072fd5e120e82919169b +R 4923ac24d6c3e1ab46abc7fb252aa8ec U drh -Z 5cf9ad391dbbe3a117e87c8cd398587f +Z efd8646b80e7db2b7d1ed86dbeee5059 diff --git a/manifest.uuid b/manifest.uuid index e3c694974d..1132ef58d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c74c07cc86443057d34284ae31eb68470741592b0e61072fd5e120e82919169b \ No newline at end of file +fbba89dac9591c56da81bd0808910fbc64640f3ccfd95845ecab4d3aea46ca61 \ No newline at end of file