GVariant: Better handling of invalid UTF-8
authorRyan Lortie <desrt@desrt.ca>
Wed, 4 May 2011 16:12:31 +0000 (18:12 +0200)
committerRyan Lortie <desrt@desrt.ca>
Wed, 4 May 2011 16:20:23 +0000 (18:20 +0200)
commite823ba10d3babd5ae61c69d96379ff34e9e978f8
treed1019a29d88bc7f05483bf27c33cbc40bf2645b6
parentd97cbc6731deab137770bc0fe9c69b06f689f5b4
GVariant: Better handling of invalid UTF-8

g_variant_new_string() hits a g_return_if_fail() when given invalid
UTF-8.  That's certainly the right thing to do, but
g_variant_builder_add() uses this function internally and crashes when
it returns NULL due to the user passing a non-utf8 string.

We can protect the internal code by returning "[Invalid UTF-8]" in this
case while also making the problem easier to debug (and less fatal).

Closes #632631.
glib/gvariant.c