[Libvir] [patch 1/5] iptables: fix invalid free
Mark McLoughlin
markmc at redhat.com
Thu Mar 22 17:13:35 UTC 2007
On Thu, 2007-03-22 at 13:01 -0400, Daniel Veillard wrote:
> Index: qemud/iptables.c
Hmm, this stuff is already in one of the patches I sent.
>
> - if (!(argv = (char **)malloc(sizeof(char *) * (n+1))))
> + if (!(argv = (char **)calloc(1, sizeof(char *) * (n + 1))))
I'd do:
if (!(argv = (char **)calloc(n + 1, sizeof(char *))))
Unless, of course, you're just being ironic about how stupid it is that
we have calloc() rather than malloc0() ... in which case I thoroughly
approve :-)
Same thing elsewhere in the patch e.g.
> - if (!(*argv = malloc(len * sizeof(char *))))
> + if (!(*argv = calloc(1, len * sizeof(char *))))
should be:
if (!(*argv = calloc(len, sizeof(char *))))
Cheers,
Mark.
More information about the libvir-list
mailing list