summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-message.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 15:05:50 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 15:05:50 -0500
commitbcf88fc3f14867f1cabc911c27b661d738281df0 (patch)
treef3965824f134a2b7a7c3f68ccfeeb8fb5570fe5a /src/libsystemd/sd-bus/bus-message.c
parent2558691285b2f7b3078b43b26736fcadf3c6d194 (diff)
bus: fix leak in error path
CID #1271349.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-message.c')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 77216a6f49..7eac069e98 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -440,7 +440,7 @@ int bus_message_from_header(
size_t extra,
sd_bus_message **ret) {
- sd_bus_message *m;
+ _cleanup_free_ sd_bus_message *m = NULL;
struct bus_header *h;
size_t a, label_sz;
@@ -459,15 +459,13 @@ int bus_message_from_header(
return -EBADMSG;
h = header;
- if (h->version != 1 &&
- h->version != 2)
+ if (!IN_SET(h->version, 1, 2))
return -EBADMSG;
if (h->type == _SD_BUS_MESSAGE_TYPE_INVALID)
return -EBADMSG;
- if (h->endian != BUS_LITTLE_ENDIAN &&
- h->endian != BUS_BIG_ENDIAN)
+ if (!IN_SET(h->endian, BUS_LITTLE_ENDIAN, BUS_BIG_ENDIAN))
return -EBADMSG;
/* Note that we are happy with unknown flags in the flags header! */
@@ -556,6 +554,7 @@ int bus_message_from_header(
m->bus = sd_bus_ref(bus);
*ret = m;
+ m = NULL;
return 0;
}