[PATCH 3/3] virLogCleanerShutdown: Don't call g_regex_unref on NULL regex

Peter Krempa posted 3 patches 2 years, 11 months ago
[PATCH 3/3] virLogCleanerShutdown: Don't call g_regex_unref on NULL regex
Posted by Peter Krempa 2 years, 11 months ago
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: 69eeef5dfbf
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/logging/log_cleaner.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/logging/log_cleaner.c b/src/logging/log_cleaner.c
index bb8f719f1b..38f818f177 100644
--- a/src/logging/log_cleaner.c
+++ b/src/logging/log_cleaner.c
@@ -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);
 }
-- 
2.39.1
Re: [PATCH 3/3] virLogCleanerShutdown: Don't call g_regex_unref on NULL regex
Posted by Daniel P. Berrangé 2 years, 11 months ago
On Wed, Feb 15, 2023 at 11:06:11AM +0100, Peter Krempa wrote:
> 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: 69eeef5dfbf
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/logging/log_cleaner.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|