mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
util: Add object checking for virObject{Ref|Unref}
Rather than assuming that what's passed to virObject{Ref|Unref} would be a virObjectPtr as long as it's not NULL, let's do the similar checks virObjectIsClass in order to prevent a possible increment or decrement to some field at the obj->u.s.refs offset. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
dfa0efbb77
commit
d3e17259e1
@ -343,7 +343,7 @@ virObjectUnref(void *anyobj)
|
||||
{
|
||||
virObjectPtr obj = anyobj;
|
||||
|
||||
if (!obj)
|
||||
if (VIR_OBJECT_NOTVALID(obj))
|
||||
return false;
|
||||
|
||||
bool lastRef = virAtomicIntDecAndTest(&obj->u.s.refs);
|
||||
@ -382,7 +382,7 @@ virObjectRef(void *anyobj)
|
||||
{
|
||||
virObjectPtr obj = anyobj;
|
||||
|
||||
if (!obj)
|
||||
if (VIR_OBJECT_NOTVALID(obj))
|
||||
return NULL;
|
||||
virAtomicIntInc(&obj->u.s.refs);
|
||||
PROBE(OBJECT_REF, "obj=%p", obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user