Skip to content

Backport !3555 “gkeyfile: Fix overwriting of GError” to glib-2-76

When parsing a line of "key3=foo\i" in a keyfile, g_key_file_parse_value_as_string currently first sets the error to 'contains invalid escape' and later to 'contains escape character at end of line'.

This leaks the first GError and causes the following warning message: Error set over the top of a previous GError or uninitialized memory. This indicates a bug in someone's code. You must ensure an error is NULL before it's set. The overwriting error message was: Key file contains escape character at end of line

Fix this by returning when an error is detected. As we may have collected data in pieces, we instead collect to a tmp_pieces GSList and free it on error.


Trivial backport of !3555 (merged) to glib-2-76.

Merge request reports