Skip to content

Commit abf237c

Browse files
committed
Make sure to cleanup old vm when xFilter is called multiple times
1 parent 1903234 commit abf237c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "sqlite3.h"
1717
#endif
1818

19-
#define CLOUDSYNC_VERSION "0.8.11"
19+
#define CLOUDSYNC_VERSION "0.8.12"
2020

2121
int sqlite3_cloudsync_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
2222

src/vtab.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ int cloudsync_changesvtab_filter (sqlite3_vtab_cursor *cursor, int idxn, const c
389389
char *sql = build_changes_sql(db, idxs);
390390
if (sql == NULL) return SQLITE_NOMEM;
391391

392+
// the xFilter method may be called multiple times on the same sqlite3_vtab_cursor*
393+
if (c->vm) sqlite3_finalize(c->vm);
394+
c->vm = NULL;
395+
392396
int rc = sqlite3_prepare_v2(db, sql, -1, &c->vm, NULL);
393397
cloudsync_memory_free(sql);
394398
if (rc != SQLITE_OK) goto abort_filter;

0 commit comments

Comments
 (0)