From 28331deae2c9a084d101a1ee38296283387f314d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 12 Dec 2023 09:19:51 +0100 Subject: [PATCH] gobject: adjust assertion for ref-count in g_object_freeze_notify() g_atomic_int_get() returns a signed int. While we don't expect this to be ever negative, a negative value would also indicate a bug. Adjust the check to assert against negative ref-count too. --- gobject/gobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gobject/gobject.c b/gobject/gobject.c index cf2f2801d..474f1b620 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -1433,7 +1433,7 @@ g_object_freeze_notify (GObject *object) g_return_if_fail (G_IS_OBJECT (object)); #ifndef G_DISABLE_CHECKS - if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) == 0)) + if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) <= 0)) { g_critical ("Attempting to freeze the notification queue for object %s[%p]; " "Property notification does not work during instance finalization.", @@ -1643,7 +1643,7 @@ g_object_thaw_notify (GObject *object) g_return_if_fail (G_IS_OBJECT (object)); #ifndef G_DISABLE_CHECKS - if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) == 0)) + if (G_UNLIKELY (g_atomic_int_get (&object->ref_count) <= 0)) { g_critical ("Attempting to thaw the notification queue for object %s[%p]; " "Property notification does not work during instance finalization.",