g_strerror() returns NULL if g_locale_to_utf8() fails.
Submitted by Enrico Jorns
Link to original bug (#793377)
Description
According to the documentation (and the usage) g_strerror() always returns a valid string.
I have a system with a possibly messed up locale setup. This actually make g_locale_to_utf8() fail. This case is somehow handled in g_strerror() as it checks for an error and simply prints the error message, but this handling seems to be insufficient.
In case of an error not only the error
variable will be set but also msg
will be set to the return value of g_locale_to_utf8()
which is simply NULL then.
As a consequence, g_strerror() unconditionally returns msg
, meaning it returns NULL
which then triggers assertion errors, when being passed to g_set_error_literal()
for example:
| g_error_new_literal: assertion 'message != NULL' failed | g_task_return_error: assertion 'error != NULL' failed
I would assume checking this case in g_strerror() and returning a dummy/error string will fix this handling?