X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qom%2Fobject.c;h=d34608558e9e5e53f4b363774f06b810f49ca36c;hb=fd6c979e651a2163062b746e01adf6f267c8e874;hp=9f7a33139d4f07c00fa2a4cd16c76f01a15f4362;hpb=4aa2e497a98bafe962e72997f67a369e4b52d9c1;p=mirror_qemu.git diff --git a/qom/object.c b/qom/object.c index 9f7a33139d..d34608558e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -16,6 +16,7 @@ #include "qom/object.h" #include "qom/object_interfaces.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "qapi/visitor.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" @@ -1167,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; }