summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-bus/bus-error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-bus/bus-error.c')
-rw-r--r--src/libsystemd/sd-bus/bus-error.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c
index 7483b46a11..bdfa145ab7 100644
--- a/src/libsystemd/sd-bus/bus-error.c
+++ b/src/libsystemd/sd-bus/bus-error.c
@@ -252,10 +252,15 @@ int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_li
return -ENOMEM;
}
- /* If we hit OOM on formatting the pretty message, we ignore
- * this, since we at least managed to write the error name */
- if (format)
- (void) vasprintf((char**) &e->message, format, ap);
+ if (format) {
+ _cleanup_free_ char *mesg = NULL;
+
+ /* If we hit OOM on formatting the pretty message, we ignore
+ * this, since we at least managed to write the error name */
+
+ if (vasprintf(&mesg, format, ap) >= 0)
+ e->message = TAKE_PTR(mesg);
+ }
e->_need_free = 1;
}