diff options
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/qom/object.c b/qom/object.c index 4048a2fef1..d34608558e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1168,10 +1168,14 @@ GSList *object_class_get_list_sorted(const char *implements_type, Object *object_ref(void *objptr) { Object *obj = OBJECT(objptr); + uint32_t ref; + if (!obj) { return NULL; } - qatomic_inc(&obj->ref); + ref = qatomic_fetch_inc(&obj->ref); + /* Assert waaay before the integer overflows */ + g_assert(ref < INT_MAX); return obj; } |