From 17e03effdac249b84153bf2d9b0d665078129873 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 8 Jan 2018 22:13:03 -0800 Subject: [PATCH] gbookmarkfile: check length before dereferencing groups There is no requirement that groups is NULL terminated, so we should check that the bounds are within the specified length before checking for a NULL terminating value. https://bugzilla.gnome.org/show_bug.cgi?id=792351 --- glib/gbookmarkfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index 92a5e0f19..4661b9daf 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -2862,7 +2862,7 @@ g_bookmark_file_set_groups (GBookmarkFile *bookmark, if (groups) { - for (i = 0; groups[i] != NULL && i < length; i++) + for (i = 0; i < length && groups[i] != NULL; i++) item->metadata->groups = g_list_append (item->metadata->groups, g_strdup (groups[i])); }