]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: avoid alloc and missing oom check in bus_match_dump()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 4 Mar 2021 20:22:47 +0000 (21:22 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 6 Mar 2021 08:32:18 +0000 (09:32 +0100)
src/libsystemd/sd-bus/bus-match.c

index f624d1ab3ca8b2c1816a226f0a76600efaa6ef2e..eb719c01055d58a50a2d4bf7403baed5d98c5cd5 100644 (file)
@@ -1017,14 +1017,12 @@ const char* bus_match_node_type_to_string(enum bus_match_node_type t, char buf[]
 }
 
 void bus_match_dump(FILE *out, struct bus_match_node *node, unsigned level) {
-        _cleanup_free_ char *pfx = NULL;
         char buf[32];
 
         if (!node)
                 return;
 
-        pfx = strrep("  ", level);
-        fprintf(out, "%s[%s]", strempty(pfx), bus_match_node_type_to_string(node->type, buf, sizeof(buf)));
+        fprintf(out, "%*s[%s]", 2 * level, "", bus_match_node_type_to_string(node->type, buf, sizeof(buf)));
 
         if (node->type == BUS_MATCH_VALUE) {
                 if (node->parent->type == BUS_MATCH_MESSAGE_TYPE)