提交 ef4719ac 编写于 作者: M Michal Privoznik

virQEMUCapsNewBinary: Avoid NULL dereference

Even with GLib it is still possible for virQEMUCapsNew() to
return NULL because it calls virQEMUCapsInitialize() which is a
wrapper over pthread_once() which may fail. At least, we still
check for its retval. If it so happens that the virQEMUCapsNew()
fails and returns NULL, we should not dereference it.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 de1ac593
...@@ -1713,7 +1713,8 @@ virQEMUCapsNewBinary(const char *binary) ...@@ -1713,7 +1713,8 @@ virQEMUCapsNewBinary(const char *binary)
{ {
virQEMUCapsPtr qemuCaps = virQEMUCapsNew(); virQEMUCapsPtr qemuCaps = virQEMUCapsNew();
qemuCaps->binary = g_strdup(binary); if (qemuCaps)
qemuCaps->binary = g_strdup(binary);
return qemuCaps; return qemuCaps;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册