Commit 1cac469c authored by Carlos Garnacho's avatar Carlos Garnacho

libtracker-data: Ensure triples cursor is entirely reset on filter()

The cursor may actually be reused multiple times for different values,
in which case we'd get filter() called again on it. Ensure the cursor
is properly reset so it can handle later items as if brand new.
parent 067ccc63
......@@ -98,17 +98,24 @@ tracker_triples_vtab_free (gpointer data)
}
static void
tracker_triples_cursor_free (gpointer data)
tracker_triples_cursor_reset (TrackerTriplesCursor *cursor)
{
TrackerTriplesCursor *cursor = data;
if (cursor->stmt)
sqlite3_finalize (cursor->stmt);
g_clear_pointer (&cursor->stmt, sqlite3_finalize);
g_clear_pointer (&cursor->match.graph, sqlite3_value_free);
g_clear_pointer (&cursor->match.subject, sqlite3_value_free);
g_clear_pointer (&cursor->match.predicate, sqlite3_value_free);
g_list_free (cursor->properties);
g_clear_pointer (&cursor->properties, g_list_free);
cursor->match.idxFlags = 0;
cursor->rowid = 0;
cursor->finished = FALSE;
}
static void
tracker_triples_cursor_free (gpointer data)
{
TrackerTriplesCursor *cursor = data;
tracker_triples_cursor_reset (cursor);
g_free (cursor);
}
......@@ -414,6 +421,8 @@ triples_filter (sqlite3_vtab_cursor *vtab_cursor,
TrackerTriplesCursor *cursor = (TrackerTriplesCursor *) vtab_cursor;
int rc;
tracker_triples_cursor_reset (cursor);
if (idx & IDX_COL_GRAPH) {
int idx = idx_str[COL_GRAPH];
cursor->match.graph = sqlite3_value_dup (argv[idx]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment