qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] linux-user: Protect against allocation failure


From: malc
Subject: Re: [Qemu-devel] [PATCH] linux-user: Protect against allocation failure in load_symbols.
Date: Fri, 30 Jul 2010 17:42:26 +0400 (MSD)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

On Fri, 30 Jul 2010, Jay Foad wrote:

> > +    /* Attempt to free the storage associated with the local symbols
> > +       that we threw away.  Whether or not this has any effect on the
> > +       memory allocation depends on the malloc implementation and how
> > +       many symbols we managed to discard.  */
> >      syms = realloc(syms, nsyms * sizeof(*syms));
> > +    if (syms == NULL) {
> > +        free(s);
> > +        free(strings);
> > +        return;
> > +    }
> 
> If realloc() fails it leaves the original object unchanged, so can't
> you just write:

Life is not as simple as one would like it to be.
http://www.mail-archive.com/address@hidden/msg22137.html

> 
>     t = realloc(syms, nsyms * sizeof(*syms));
>     if (t != NULL) {
>         syms = t;
>     }
> 
> ?
> 
> Jay.
> 

-- 
mailto:address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]