diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.c | 13 | ||||
-rw-r--r-- | src/libutil/util.h | 6 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 035369e67..0002c84de 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -1973,12 +1973,17 @@ rspamd_gstring_free_hard (gpointer p) g_string_free (ar, TRUE); } -void -rspamd_gstring_free_soft (gpointer p) +void rspamd_gerror_free_maybe (gpointer p) { - GString *ar = (GString *)p; + GError **err; + + if (p) { + err = (GError **)p; - g_string_free (ar, FALSE); + if (*err) { + g_error_free (*err); + } + } } struct rspamd_external_libs_ctx * diff --git a/src/libutil/util.h b/src/libutil/util.h index a1b4f95bb..adb645600 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -331,6 +331,12 @@ void rspamd_array_free_hard (gpointer p); void rspamd_gstring_free_hard (gpointer p); /** + * Special utility to help GError freeing in rspamd_mempool + * @param p + */ +void rspamd_gerror_free_maybe (gpointer p); + +/** * Special utility to help GString freeing (without freeing the memory segment) in rspamd_mempool * @param p */ |