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

[Xen-changelog] [xen-unstable] tools: Fix xenstored build error by checking vasprintf() return code.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1181501902 -3600
# Node ID 93f77a5a8437df0b34919a6987f48e84342b4a43
# Parent  7eeddd787d2f8fb3cc27680d0358fe88eeaf342c
tools: Fix xenstored build error by checking vasprintf() return code.
Signed-off-by: Charles Coffing <ccoffing@xxxxxxxxxx>
---
 tools/xenstore/utils.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff -r 7eeddd787d2f -r 93f77a5a8437 tools/xenstore/utils.c
--- a/tools/xenstore/utils.c    Sun Jun 10 19:49:44 2007 +0100
+++ b/tools/xenstore/utils.c    Sun Jun 10 19:58:22 2007 +0100
@@ -27,33 +27,38 @@ void barf(const char *fmt, ...)
 void barf(const char *fmt, ...)
 {
        char *str;
+       int bytes;
        va_list arglist;
 
        xprintf("FATAL: ");
 
        va_start(arglist, fmt);
-       vasprintf(&str, fmt, arglist);
+       bytes = vasprintf(&str, fmt, arglist);
        va_end(arglist);
 
-       xprintf("%s\n", str);
-       free(str);
+       if (bytes >= 0) {
+               xprintf("%s\n", str);
+               free(str);
+       }
        exit(1);
 }
 
 void barf_perror(const char *fmt, ...)
 {
        char *str;
-       int err = errno;
+       int bytes, err = errno;
        va_list arglist;
 
        xprintf("FATAL: ");
 
        va_start(arglist, fmt);
-       vasprintf(&str, fmt, arglist);
+       bytes = vasprintf(&str, fmt, arglist);
        va_end(arglist);
 
-       xprintf("%s: %s\n", str, strerror(err));
-       free(str);
+       if (bytes >= 0) {
+               xprintf("%s: %s\n", str, strerror(err));
+               free(str);
+       }
        exit(1);
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.