[libvirt] [PATCH] tests: avoid NULL deref upon OOM failure
Daniel Veillard
veillard at redhat.com
Tue Feb 16 16:43:00 UTC 2010
On Tue, Feb 16, 2010 at 09:39:25AM +0100, Jim Meyering wrote:
> Pretty obvious:
>
> >From 3e79d8839c5051461197a7c484adb32f7f04377a Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Tue, 16 Feb 2010 09:36:57 +0100
> Subject: [PATCH] tests: avoid NULL deref upon OOM failure
>
> * tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Handle malloc
> failure.
> ---
> tests/qemuxml2argvtest.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 3ee71a3..aa42f99 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -98,7 +98,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
> len += strlen(*tmp) + 1;
> tmp++;
> }
> - actualargv = malloc(sizeof(*actualargv)*len);
> + if ((actualargv = malloc(sizeof(*actualargv)*len)) == NULL)
> + goto fail;
> actualargv[0] = '\0';
> tmp = qenv;
> while (*tmp) {
sure, ACK
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list