aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2019-01-01 18:00:17 +0000
committerdan <dan@noemail.net>2019-01-01 18:00:17 +0000
commit97c8cb3ed8adb0867db29dbc24b2df9d35fb1d88 (patch)
treede04cb7d90b9bbbfa731891093d2bcae001f9310 /src
parentfff1dc8e058f8f676196a39d349ae7f8d81fd7e7 (diff)
downloadsqlite-97c8cb3ed8adb0867db29dbc24b2df9d35fb1d88.tar.gz
sqlite-97c8cb3ed8adb0867db29dbc24b2df9d35fb1d88.zip
Ensure that when a new cursor is opened by OP_OpenDup, any existing cursor
with the same id opened by a previous OP_OpenDup is closed first. FossilOrigin-Name: 5c188361a91407805c0feb4bf6d3214522ce3e55013efcf63a4613ecd416bcbc
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;
}