Commit 3c49c593 authored by John Ralls's avatar John Ralls

[GtkSearchEngineQuartz] Don't run off the end of the results array and crash.

parent 5ecc3080
Pipeline #50762 passed with stage
in 6 minutes and 11 seconds
......@@ -73,12 +73,14 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT
{
int i;
GList *hits = NULL;
/* The max was originally set to 1000 to mimic the Beagle backend. */
const unsigned int max_hits = 1000;
const unsigned int max_iter = submitted_hits + [ns_query resultCount];
/* The max was originally set to 1000 to mimic something called "the
* boogie backend". submitted_hits contains the number of hits we've
* processed in previous calls to this function.
*/
const unsigned int max_hits = 1000 - submitted_hits;
const unsigned int max_iter = [ns_query resultCount];
/* Here we submit hits "submitted_hits" to "resultCount" */
for (i = submitted_hits; i < max_iter && i < max_hits; ++i)
for (i = 0; i < max_iter && i < max_hits; ++i)
{
id result = [ns_query resultAtIndex:i];
const char *result_path;
......@@ -101,7 +103,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT
if (max_iter >= max_hits)
[ns_query stopQuery];
submitted_hits = max_iter;
submitted_hits += max_iter;
}
- (void) queryUpdate:(id)sender
......
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