[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] tests: avoid NULL deref upon OOM failure



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 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 veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]