virLogCleanerShutdown: Don't call g_regex_unref on NULL regex

Shutdown of virtlogd prints:

  (process:54742): GLib-CRITICAL **: 11:00:40.873: g_regex_unref: assertion 'regex != NULL' failed

Use g_clear_pointer instead which prevents it in the NULL case.

Fixes: 69eeef5dfb
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Peter Krempa 2023-02-15 11:02:10 +01:00
parent b3f8e072fe
commit 8c8eff610a

View File

@ -264,6 +264,5 @@ virLogCleanerShutdown(virLogHandler *handler)
handler->cleanup_log_timer = -1;
}
g_regex_unref(log_regex);
log_regex = NULL;
g_clear_pointer(&log_regex, g_regex_unref);
}