[gnome-builder] plugins/c-pack: be tolerant of calls past end of list
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/c-pack: be tolerant of calls past end of list
- Date: Tue, 11 Oct 2022 16:36:42 +0000 (UTC)
commit 2637417af692ff013ddab805f92e46a22cb1c240
Author: Christian Hergert <chergert redhat com>
Date: Tue Oct 11 11:36:23 2022 -0500
plugins/c-pack: be tolerant of calls past end of list
GTK can do this to discover the end of a list model and we need to be
more tolerant of that.
Fixes #1860
src/plugins/c-pack/cpack-completion-results.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/c-pack/cpack-completion-results.c b/src/plugins/c-pack/cpack-completion-results.c
index 50cdd5e8d..39200292e 100644
--- a/src/plugins/c-pack/cpack-completion-results.c
+++ b/src/plugins/c-pack/cpack-completion-results.c
@@ -106,15 +106,14 @@ static gpointer
cpack_completion_results_get_item (GListModel *model,
guint position)
{
- CpackCompletionResults *self = (CpackCompletionResults *)model;
- const Item *item;
+ CpackCompletionResults *self = CPACK_COMPLETION_RESULTS (model);
g_assert (CPACK_IS_COMPLETION_RESULTS (self));
- g_assert (position < self->items->len);
- item = &g_array_index (self->items, Item, position);
+ if (position >= self->items->len)
+ return NULL;
- return cpack_completion_item_new (item->word);
+ return cpack_completion_item_new (g_array_index (self->items, Item, position).word);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]