gutf8: Assert that written memory stays in bounds

You may expect funny effects from passing invalid UTF-8, but not
that funny. The assert will probably be a better and more immediate
confirmation of an error than invalid writes under the address of the
string copy.

https://gitlab.gnome.org/GNOME/glib/issues/1863
This commit is contained in:
Carlos Garnacho 2019-08-07 23:18:42 +02:00
parent 179fdc5239
commit 154f6cafa9

View File

@ -1773,6 +1773,7 @@ g_utf8_strreverse (const gchar *str,
{
gchar *m, skip = g_utf8_skip[*(guchar*) p];
r -= skip;
g_assert (r >= result);
for (m = r; skip; skip--)
*m++ = *p++;
}