[fedora-virt] [PATCH libguestfs] use xmalloc and xcalloc in generated code
Richard W.M. Jones
rjones at redhat.com
Thu Jul 2 21:21:23 UTC 2009
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.
More information about the Fedora-virt
mailing list