GNOME Bugzilla – Bug 773842
[PATCH] g_utf8_find_next_char() won't signal the end of a NUL-terminated string
Last modified: 2017-06-21 10:40:26 UTC
Created attachment 338964 [details] [review] [PATCH] Return NULL when g_utf8_find_next_char() reached terminating nul This use of g_utf8_find_next_char() proceeds beyond the end of the string: https://git.gnome.org/browse/gnome-control-center/tree/shell/hostname-helper.c?h=gnome-3-22#n198
Ping?
Review of attachment 338964 [details] [review]: No, this would be an API break; there are cases in the wild where callers will unconditionally dereference the return value from g_utf8_find_next_char(). Returning NULL will cause them to crash. For example, see g_key_file_is_group_name() in gkeyfile.c in GLib. We can improve the documentation to make this clearer, but we can’t change the behaviour of g_utf8_find_next_char().
Created attachment 354096 [details] [review] gutf8: Clarify return value docs for g_utf8_find_next_char() Make it clearer that it will only return NULL if @end is non-NULL. Add a test for this too. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Review of attachment 354096 [details] [review]: Looks good.
Attachment 354096 [details] pushed as 1366ce7 - gutf8: Clarify return value docs for g_utf8_find_next_char()