GNOME Bugzilla – Bug 788458
gtk+-3.22.22/gtk/updateiconcache.c:287]: (style) Array index 'i' is used before limits check.
Last modified: 2017-10-04 22:03:52 UTC
Source code is while (split[i] != NULL && i < data->n_attach_points) Maybe better code while (i < data->n_attach_points && split[i] != NULL)
split[] is the result of g_strsplit(), which returns a NULL-terminated array. So it doesn't actually matter. The condition is confusing, though; we shouldn't need to check both of those, as they should always both be TRUE or both be FALSE.
Created attachment 360932 [details] [review] updateiconcache: Avoid confusing loop construct n_attach_points is the result of g_strv_length(), i.e. the index at which the string vector ends in NULL. So, by definition, when i == n_attach_points, string[i] == NULL, and there is no need to check for the latter. The fact that we did appears to confuse static analysers.
Created attachment 360933 [details] [review] updateiconcache: Avoid confusing loop construct n_attach_points is the result of g_strv_length(): the index at which the string vector ends in NULL. So by definition, when i == n_attach_points, string[i] == NULL, and there is no need to check for the latter. The fact that we did appears to confuse static analysers, as the dereference and index check were inverted from what would normally be safe. We could reverse them, but we may as well just remove the unnecessary NULL check.
Attachment 360933 [details] pushed as 512a33f - updateiconcache: Avoid confusing loop construct