提交 9a471495 编写于 作者: D Daniel P. Berrange

Fix misc memory handling bugs

上级 83a618f8
Wed Apr 1 11:18:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Misc memory handling fixes
* src/node_device.c: Don't strdup() a NULL parent device name
* src/qemu_conf.c: Don't try to access() a NULL alternative
binary name
* src/storage_conf.c: Don't free mode string while its still
in use
Wed Apr 1 11:16:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* src/xm_internal.c: Add support for vifname= parameter in
......
......@@ -175,9 +175,14 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev)
goto cleanup;
}
ret = strdup(obj->def->parent);
if (!ret)
virReportOOMError(dev->conn);
if (obj->def->parent) {
ret = strdup(obj->def->parent);
if (!ret)
virReportOOMError(dev->conn);
} else {
virNodeDeviceReportError(dev->conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("no parent for this device"));
}
cleanup:
if (obj)
......
......@@ -269,7 +269,7 @@ qemudCapsInitGuest(virCapsPtr caps,
* which can be used with magic cpu choice
*/
hasbase = (access(info->binary, X_OK) == 0);
hasaltbase = (access(info->altbinary, X_OK) == 0);
hasaltbase = (info->altbinary && access(info->altbinary, X_OK) == 0);
/* Can use acceleration for KVM/KQEMU if
* - host & guest arches match
......
......@@ -401,12 +401,13 @@ virStorageDefParsePerms(virConnectPtr conn,
} else {
char *end = NULL;
perms->mode = strtol(mode, &end, 8);
VIR_FREE(mode);
if (*end || perms->mode < 0 || perms->mode > 0777) {
VIR_FREE(mode);
virStorageReportError(conn, VIR_ERR_XML_ERROR,
"%s", _("malformed octal mode"));
goto error;
}
VIR_FREE(mode);
}
if (virXPathNode(conn, "./owner", ctxt) == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册