sd-bus: check return value of vasprintf

Check for OOM situations when vasprintf() returns < 0 in bus_error_setfv().

Spotted by coverity.
This commit is contained in:
Daniel Mack
2014-10-07 12:10:06 +02:00
parent 53e9dbcdfb
commit 8bf13eb1e0
+7 -2
View 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;