Fix GError handling
Several users have reported segfaults when starting up profanity which has OMEMO support, but OMEMO is not set up yet. @StefanKropp has been able to reproduce this and tracked it down to `_load_identity()` calling `omemo_known_devices_keyfile_save()`. The latter then calls `save_keyfile()` which calls `g_key_file_save_to_file()`. This can then fail if one of the first two strings is NULL and won't set the `error` on return. In its error handling `save_keyfile()` unconditionally dereferences `error` which leads to the segfault. Fix this and also go through the entire codebase and verify that the usage of `GError` is done correctly. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -93,9 +93,9 @@ main(int argc, char** argv)
|
||||
context = g_option_context_new(NULL);
|
||||
g_option_context_add_main_entries(context, entries, NULL);
|
||||
if (!g_option_context_parse(context, &argc, &argv, &error)) {
|
||||
g_print("%s\n", error->message);
|
||||
g_print("%s\n", PROF_GERROR_MESSAGE(error));
|
||||
g_option_context_free(context);
|
||||
g_error_free(error);
|
||||
PROF_GERROR_FREE(error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user