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

Re: [fedora-virt] [PATCH libguestfs] use xmalloc and xcalloc in generated code



On Thu, Jul 02, 2009 at 11:16:37PM +0200, Jim Meyering wrote:
> Hi Rich,
> 
> I noticed that there were some unchecked malloc and calloc return values.
> That could result in NULL deref upon failed allocation.  Based on what
> you said about there not being much point in trying to recover from OOM
> errors, I made the small textual change to convert e.g., malloc(n) to
> xmalloc(g,n) where xmalloc now ends up calling g->abort_cb upon malloc
> failure.  Then any following dereference of the result is guaranteed to
> be valid.

I think the patch is fine, but I generally wonder why we now have
functions which do the same thing called xmalloc and
[guestfs_]safe_malloc?

Rich.


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