summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-dump.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-26 20:03:25 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-26 21:52:07 +0100
commitee04388a54f0e045377eeaf33c17eb357fe12d69 (patch)
treeee9ccbab72ceebc4bd7ecab8f93df50c0bfab611 /src/libsystemd/sd-bus/bus-dump.c
parentad4cdc551588ee543ab1c2b3adfcadf0a2040f23 (diff)
bus-dump: fix two minor memory leaks
Diffstat (limited to 'src/libsystemd/sd-bus/bus-dump.c')
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 8fba7ac679..e27d8027de 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -129,8 +129,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
if (r < 0)
return log_error_errno(r, "Failed to rewind: %m");
- if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
- fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature));
+ if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
+ _cleanup_free_ char *prefix = NULL;
+
+ prefix = indent(0, flags);
+ if (!prefix)
+ return log_oom();
+
+ fprintf(f, "%sMESSAGE \"%s\" {\n", prefix, strempty(m->root_container.signature));
+ }
for (;;) {
_cleanup_free_ char *prefix = NULL;
@@ -259,8 +266,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
}
}
- if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
- fprintf(f, "%s};\n\n", indent(0, flags));
+ if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
+ _cleanup_free_ char *prefix = NULL;
+
+ prefix = indent(0, flags);
+ if (!prefix)
+ return log_oom();
+
+ fprintf(f, "%s};\n\n", prefix);
+ }
return 0;
}