Subject: | free() the arrays before _croak_error() |
Several of the methods bail out using _croak_error().
Shouldn't the allocated array be freed before that?
(The patch comes from Fedora perl-Sys-Virt-0.2.0-1.fc11 rpm.
Subject: | perl-Sys-Virt-free.patch |
2009-03-30 Stepan Kasal <skasal@redhat.com>
* Virt.xs: call Safefree before bailing out.
Adapted from a similar patch to Sys-Virt-0.1.2.
diff -urpN Sys-Virt-0.2.0.orig/Virt.xs Sys-Virt-0.2.0/Virt.xs
--- Sys-Virt-0.2.0.orig/Virt.xs 2009-03-27 20:45:33.000000000 +0100
+++ Sys-Virt-0.2.0/Virt.xs 2009-03-30 16:51:16.000000000 +0200
@@ -670,6 +670,7 @@ list_domain_ids(con, maxids)
PPCODE:
Newx(ids, maxids, int);
if ((nid = virConnectListDomains(con, ids, maxids)) < 0) {
+ Safefree(ids);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, nid);
@@ -700,7 +701,7 @@ list_defined_domain_names(con, maxnames)
PPCODE:
Newx(names, maxnames, char *);
if ((ndom = virConnectListDefinedDomains(con, names, maxnames)) < 0) {
- free(names);
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, ndom);
@@ -731,6 +732,7 @@ list_network_names(con, maxnames)
PPCODE:
Newx(names, maxnames, char *);
if ((nnet = virConnectListNetworks(con, names, maxnames)) < 0) {
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, nnet);
@@ -762,7 +764,7 @@ list_defined_network_names(con, maxnames
PPCODE:
Newx(names, maxnames, char *);
if ((ndom = virConnectListDefinedNetworks(con, names, maxnames)) < 0) {
- free(names);
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, ndom);
@@ -793,6 +795,7 @@ list_storage_pool_names(con, maxnames)
PPCODE:
Newx(names, maxnames, char *);
if ((nnet = virConnectListStoragePools(con, names, maxnames)) < 0) {
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, nnet);
@@ -824,7 +827,7 @@ list_defined_storage_pool_names(con, max
PPCODE:
Newx(names, maxnames, char *);
if ((ndom = virConnectListDefinedStoragePools(con, names, maxnames)) < 0) {
- free(names);
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, ndom);
@@ -859,6 +862,7 @@ list_node_device_names(con, cap, maxname
PPCODE:
Newx(names, maxnames, char *);
if ((nnet = virNodeListDevices(con, cap, names, maxnames, flags)) < 0) {
+ Safefree(names);
_croak_error(virConnGetLastError(con));
}
EXTEND(SP, nnet);