diff --git a/ChangeLog b/ChangeLog index 22295abcf3..1afec5929e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Apr 1 11:18:22 BST 2009 Daniel P. Berrange + + 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 * src/xm_internal.c: Add support for vifname= parameter in diff --git a/src/node_device.c b/src/node_device.c index b435f1a81a..b84729f778 100644 --- a/src/node_device.c +++ b/src/node_device.c @@ -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) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 50b903f2f9..f36c927cb0 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -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 diff --git a/src/storage_conf.c b/src/storage_conf.c index 1c9a4e5f02..323551839a 100644 --- a/src/storage_conf.c +++ b/src/storage_conf.c @@ -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) {