On Tue, Jun 24, 2008 at 08:51:35AM -0700, Dan Smith wrote:
Changes:
- Throw an error after parsing if nets were specified and NETNS support
is not present
Fine by me
[...]
+error_out:
+ xmlFree(macaddr);
+ macaddr = NULL;
+ xmlFree(network);
+ network = NULL;
+ xmlFree(bridge);
+ bridge = NULL;
+ xmlFree(parentIfName);
+ parentIfName = NULL;
+
+ return rc;
+}
in that case the = NULL; are superfluous as they are local variables,
but i assume the compiler optimizes this easilly :-)
+ res = virXPathNodeSet("/domain/devices/interface",
contextPtr, &list);
+ if (res > 0) {
+ for (i = 0; i < res; ++i) {
+ netDef = calloc(1, sizeof(lxc_net_def_t));
+ if (NULL == netDef) {
+ lxcError(conn, NULL, VIR_ERR_NO_MEMORY,
+ _("No storage for net def structure"));
-> list need to be freed here or you leak
+ goto parse_complete;
+ }
+
+ rc = lxcParseInterfaceXML(conn, list[i], netDef);
+ if (0 > rc) {
+ DEBUG("failed parsing a net: %d", rc);
+
+ free(netDef);
-> same here list need to be freed here or you leak
+ goto parse_complete;
+ }
+
+ DEBUG0("parsed a net");
+
+ /* set the linked list pointers */
+ numNets++;
+ netDef->next = NULL;
+ if (0 == i) {
+ *nets = netDef;
+ } else {
+ prevDef->next = netDef;
+ }
+ prevDef = netDef;
+ }
+ free(list);
+ }
+
+ rc = numNets;
+
+parse_complete:
+ DEBUG("parsed %d nets", rc);
+ return rc;
}
Looks fine +1 once the two leaks are plugged :-)
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/