Mon Feb 26 14:20:18 IST 2007 Mark McLoughlin <markmc@redhat.com>

* qemud/conf.c: check for malloc failure in GenerateXML()
        and GenerateNetworkXML()

        * qemud/driver.c: free the XML output after returning it
        from the DumpXML() commands.
This commit is contained in:
Mark McLoughlin 2007-02-26 14:21:21 +00:00
parent 1920ed8a77
commit e0952bad01
3 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,11 @@
Mon Feb 26 14:20:18 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/conf.c: check for malloc failure in GenerateXML()
and GenerateNetworkXML()
* qemud/driver.c: free the XML output after returning it
from the DumpXML() commands.
Fri Feb 23 12:14:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/driver.c, qemud/internal.h, qemud/qemud.c, qemud/conf.c,

View File

@ -2216,6 +2216,9 @@ char *qemudGenerateXML(struct qemud_server *server,
buf.used = 0;
buf.data = malloc(buf.len);
if (!buf.data)
goto no_memory;
switch (def->virtType) {
case QEMUD_VIRT_QEMU:
type = "qemu";
@ -2432,7 +2435,8 @@ char *qemudGenerateXML(struct qemud_server *server,
no_memory:
qemudReportError(server, VIR_ERR_NO_MEMORY, "xml");
cleanup:
free(buf.data);
if (buf.data)
free(buf.data);
return NULL;
}
@ -2447,6 +2451,9 @@ char *qemudGenerateNetworkXML(struct qemud_server *server,
buf.used = 0;
buf.data = malloc(buf.len);
if (!buf.data)
goto no_memory;
if (qemudBufferPrintf(&buf, "<network>\n") < 0)
goto no_memory;
@ -2508,7 +2515,8 @@ char *qemudGenerateNetworkXML(struct qemud_server *server,
no_memory:
qemudReportError(server, VIR_ERR_NO_MEMORY, "xml");
free(buf.data);
if (buf.data)
free(buf.data);
return NULL;
}

View File

@ -432,6 +432,8 @@ int qemudDomainDumpXML(struct qemud_server *server, const unsigned char *uuid, c
strncpy(xml, vmxml, xmllen);
xml[xmllen-1] = '\0';
free(xml);
return 0;
}
@ -741,6 +743,8 @@ int qemudNetworkDumpXML(struct qemud_server *server, const unsigned char *uuid,
strncpy(xml, networkxml, xmllen);
xml[xmllen-1] = '\0';
free(xml);
return 0;
}