From 202e11543ead0d21a8485879654c927ec95ea7f0 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 1 Jul 2009 15:45:01 +0200 Subject: [PATCH] Don't dereference or free undefined "msg" upon OOM. * src/guestfs.c (guestfs_error): Handle failing vasprintf. --- src/guestfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 1.8.3.1