From: Jim Meyering Date: Wed, 1 Jul 2009 13:45:01 +0000 (+0200) Subject: Don't dereference or free undefined "msg" upon OOM. X-Git-Tag: 1.0.55~28 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=202e11543ead0d21a8485879654c927ec95ea7f0;p=libguestfs.git Don't dereference or free undefined "msg" upon OOM. * src/guestfs.c (guestfs_error): Handle failing vasprintf. --- diff --git a/src/guestfs.c b/src/guestfs.c index 5743a07..87b0d86 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -404,9 +404,11 @@ guestfs_error (guestfs_h *g, const char *fs, ...) char *msg; va_start (args, fs); - vasprintf (&msg, fs, args); + int err = vasprintf (&msg, fs, args); va_end (args); + if (err < 0) return; + if (g->error_cb) g->error_cb (g, g->error_cb_data, msg); set_last_error (g, msg);