Skip to content

Commit

Permalink
Convert an assert() in R-Tree into a database corruption detection case.
Browse files Browse the repository at this point in the history
  • Loading branch information
D. Richard Hipp committed Jul 29, 2019
1 parent 285665d commit 496878e
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/rtree/rtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,16 @@ static int nodeAcquire(
** increase its reference count and return it.
*/
if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
if( pParent && !pNode->pParent ){
if( nodeInParentChain(pNode, pParent) ){
RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
pParent->nRef++;
pNode->pParent = pParent;
}else if( pParent && pNode->pParent && pParent!=pNode->pParent ){
RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
pNode->nRef++;
*ppNode = pNode;
Expand Down
Loading

0 comments on commit 496878e

Please sign in to comment.