summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ralls <jralls@ceridwen.us>2019-01-11 16:14:00 -0800
committerJohn Ralls <jralls@ceridwen.us>2019-01-11 16:18:45 -0800
commit3c49c593f57d0153fea0c191f502addfbd8a6f61 (patch)
tree4b1a4ac32529b5c01bf28c062bcc0f442b7283e4
parent5ecc3080feddc4a46163b403eab84f356231f398 (diff)
downloadgtk+-3c49c593f57d0153fea0c191f502addfbd8a6f61.tar.gz
[GtkSearchEngineQuartz] Don't run off the end of the results array and crash.
-rw-r--r--gtk/gtksearchenginequartz.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c
index 7e9d5dd721..f408c415a8 100644
--- a/gtk/gtksearchenginequartz.c
+++ b/gtk/gtksearchenginequartz.c
@@ -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