chiark / gitweb /
sd-bus: check return value of vasprintf
[elogind.git] / src / libsystemd / sd-bus / bus-error.c
index c2e41fb..5ca974a 100644 (file)
@@ -194,8 +194,13 @@ int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_li
                 return -ENOMEM;
         }
 
-        if (format)
-                vasprintf((char**) &e->message, format, ap);
+        if (format) {
+                int r;
+
+                r = vasprintf((char**) &e->message, format, ap);
+                if (r < 0)
+                        return -ENOMEM;
+        }
 
         e->_need_free = 1;
 
@@ -312,7 +317,7 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
                         continue;
                 }
 
-                if (!x || errno) {
+                if (errno) {
                         free(m);
                         return;
                 }