]> xenbits.xensource.com Git - xen.git/commitdiff
tools: xen-mceinj: Add missing return value checks
authorBastian Blank <bastian@waldi.eu.org>
Sun, 11 Aug 2013 20:10:20 +0000 (22:10 +0200)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 13 Sep 2013 13:39:51 +0000 (14:39 +0100)
The return value of vasprintf must be checked. This check is enforced
with the compiler options used in Debian by request and in Ubuntu by
default.

Check the return value and abort on error.

Signed-off-by: Bastian Blank <waldi@debian.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
(cherry picked from commit 1efe90faa31be104a24fe75323429d227eae1d9f)

tools/tests/mce-test/tools/xen-mceinj.c

index e3e62f7855181e4ec0dea0867a9d25a753e11ed6..21a488b48f9144817841e0b206eab72106ae738f 100644 (file)
@@ -92,7 +92,8 @@ static void Lprintf(const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    vasprintf(&buf, fmt, args);
+    if (vasprintf(&buf, fmt, args) < 0)
+        abort();
     fprintf(LOGFILE, "%s", buf);
     va_end(args);
     free(buf);
@@ -104,7 +105,8 @@ static void err(xc_interface *xc_handle, const char *fmt, ...)
     va_list args;
 
     va_start(args, fmt);
-    vasprintf(&buf, fmt, args);
+    if (vasprintf(&buf, fmt, args) < 0)
+        abort();
     perror(buf);
     va_end(args);
     free(buf);