提交 94711ff7 编写于 作者: D Daniel P. Berrange

Fixed memory leaks

上级 f7dd6b4d
Tue Jul 31 10:24:23 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_conf.c, src/xml.c, tests/qemuxml2argvtest.c,
tests/qemuxml2xmltest.c: Fix a couple of memory leaks
Mon Jul 30 14:40:23 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_conf.c: Validate requested architecture and reject
......
......@@ -135,6 +135,7 @@ struct qemud_network *qemudFindNetworkByName(const struct qemud_driver *driver,
void qemudFreeVMDef(struct qemud_vm_def *def) {
struct qemud_vm_disk_def *disk = def->disks;
struct qemud_vm_net_def *net = def->nets;
struct qemud_vm_input_def *input = def->inputs;
while (disk) {
struct qemud_vm_disk_def *prev = disk;
......@@ -146,6 +147,11 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
net = net->next;
free(prev);
}
while (input) {
struct qemud_vm_input_def *prev = input;
input = input->next;
free(prev);
}
free(def);
}
......
......@@ -70,8 +70,11 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt) {
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0))
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
if (obj)
xmlXPathFreeObject(obj);
return(NULL);
}
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
......@@ -618,6 +621,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
if (str != NULL && !strcmp(str, "localtime")) {
virBufferAdd(buf, "(localtime 1)", 13);
}
if (str)
free(str);
virBufferAdd(buf, "))", 2);
......
......@@ -22,7 +22,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmd) {
char **argv = NULL;
char **tmp = NULL;
int ret = -1, len;
struct qemud_vm_def *vmdef;
struct qemud_vm_def *vmdef = NULL;
struct qemud_vm vm;
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
......@@ -80,6 +80,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmd) {
free(argv);
}
qemudFreeVMDef(vmdef);
return ret;
}
......
......@@ -19,7 +19,7 @@ static int testCompareXMLToXMLFiles(const char *xml) {
char *xmlPtr = &(xmlData[0]);
char *actual = NULL;
int ret = -1;
struct qemud_vm_def *vmdef;
struct qemud_vm_def *vmdef = NULL;
struct qemud_vm vm;
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
......@@ -48,7 +48,7 @@ static int testCompareXMLToXMLFiles(const char *xml) {
fail:
free(actual);
qemudFreeVMDef(vmdef);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册