aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c1
-rw-r--r--src/vdbe.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/src/btree.c b/src/btree.c
index 24a274cd4..b6c0a4104 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -4416,6 +4416,7 @@ int sqlite3BtreeCloseCursor(BtCursor *pCur){
sqlite3_free(pCur->aOverflow);
sqlite3_free(pCur->pKey);
sqlite3BtreeLeave(pBtree);
+ pCur->pBtree = 0;
}
return SQLITE_OK;
}
diff --git a/src/vdbe.c b/src/vdbe.c
index 3146d05d8..f8371e847 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -240,6 +240,11 @@ static VdbeCursor *allocateCursor(
assert( iCur>=0 && iCur<p->nCursor );
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
+ /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag
+ ** is clear. Otherwise, if this is an ephemeral cursor created by
+ ** OP_OpenDup, the cursor will not be closed and will still be part
+ ** of a BtShared.pCursor list. */
+ p->apCsr[iCur]->isEphemeral = 0;
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
p->apCsr[iCur] = 0;
}