`g_spawn` `GError**` handling not according to documentation
We were recently investigating an issue in profanity (which uses glib) https://github.com/profanity-im/profanity/issues/1742 resp. https://github.com/profanity-im/profanity/pull/1748
In the process we found out that the entire class of g_spawn
API breaks its promises which state e.g. for g_spawn_sync()
error
[...]
The argument will be set to NULL by the function if there are no errors.
In case of error, the argument will be set and the caller will take ownership of the data, and be responsible for freeing it.
There is a multitude of cases where g_spawn_sync()
returns with an error, but didn't set error
, e.g. already the basic sanity checks https://gitlab.gnome.org/GNOME/glib/-/blob/main/glib/gspawn.c#L384-390
I can create a patch for this issue, but before I'd like to get feedback on which of the options I should go for:
In case we'd go for if (error != NULL) *error = NULL;
at the beginning of each public API, so the user at least has a way to check whether there's something stored in error
after a call.
What do you think?