mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-22 19:46:21 +00:00
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:
10
src/common.h
10
src/common.h
@@ -112,12 +112,22 @@ void auto_close_gfd(gint* fd);
|
||||
|
||||
void auto_close_FILE(FILE** fd);
|
||||
|
||||
void auto_free_gerror(GError** err);
|
||||
#define auto_gerror __attribute__((__cleanup__(auto_free_gerror)))
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define STR_MAYBE_NULL(p) (p) ?: "(null)"
|
||||
#else
|
||||
#define STR_MAYBE_NULL(p) (p)
|
||||
#endif
|
||||
|
||||
#define PROF_GERROR_MESSAGE(err) (err) ? (err)->message : "error message missing"
|
||||
#define PROF_GERROR_FREE(err) \
|
||||
do { \
|
||||
if (err) \
|
||||
g_error_free(err); \
|
||||
} while (0)
|
||||
|
||||
typedef struct prof_keyfile_t
|
||||
{
|
||||
gchar* filename;
|
||||
|
||||
Reference in New Issue
Block a user