You need to sign in or sign up before continuing.
提交 d3e17259 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
上级 dfa0efbb
...@@ -343,7 +343,7 @@ virObjectUnref(void *anyobj) ...@@ -343,7 +343,7 @@ virObjectUnref(void *anyobj)
{ {
virObjectPtr obj = anyobj; virObjectPtr obj = anyobj;
if (!obj) if (VIR_OBJECT_NOTVALID(obj))
return false; return false;
bool lastRef = virAtomicIntDecAndTest(&obj->u.s.refs); bool lastRef = virAtomicIntDecAndTest(&obj->u.s.refs);
...@@ -382,7 +382,7 @@ virObjectRef(void *anyobj) ...@@ -382,7 +382,7 @@ virObjectRef(void *anyobj)
{ {
virObjectPtr obj = anyobj; virObjectPtr obj = anyobj;
if (!obj) if (VIR_OBJECT_NOTVALID(obj))
return NULL; return NULL;
virAtomicIntInc(&obj->u.s.refs); virAtomicIntInc(&obj->u.s.refs);
PROBE(OBJECT_REF, "obj=%p", obj); PROBE(OBJECT_REF, "obj=%p", obj);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册