|
|
803fb7 |
From 69aaf3c41923fafd9616b1bbec51fa6bcb23b886 Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
803fb7 |
Date: Sat, 7 Mar 2015 15:05:50 -0500
|
|
|
803fb7 |
Subject: [PATCH] bus: fix leak in error path
|
|
|
803fb7 |
|
|
|
803fb7 |
CID #1271349.
|
|
|
803fb7 |
|
|
|
803fb7 |
Cherry-picked from: bcf88fc3f14867f1cabc911c27b661d738281df0
|
|
|
803fb7 |
Related: #1331667
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/libsystemd/sd-bus/bus-message.c | 9 ++++-----
|
|
|
803fb7 |
1 file changed, 4 insertions(+), 5 deletions(-)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
|
|
|
803fb7 |
index 295930303..c8402a23a 100644
|
|
|
803fb7 |
--- a/src/libsystemd/sd-bus/bus-message.c
|
|
|
803fb7 |
+++ b/src/libsystemd/sd-bus/bus-message.c
|
|
|
803fb7 |
@@ -441,7 +441,7 @@ int bus_message_from_header(
|
|
|
803fb7 |
size_t extra,
|
|
|
803fb7 |
sd_bus_message **ret) {
|
|
|
803fb7 |
|
|
|
803fb7 |
- sd_bus_message *m;
|
|
|
803fb7 |
+ _cleanup_free_ sd_bus_message *m = NULL;
|
|
|
803fb7 |
struct bus_header *h;
|
|
|
803fb7 |
size_t a, label_sz;
|
|
|
803fb7 |
|
|
|
803fb7 |
@@ -460,15 +460,13 @@ int bus_message_from_header(
|
|
|
803fb7 |
return -EBADMSG;
|
|
|
803fb7 |
|
|
|
803fb7 |
h = header;
|
|
|
803fb7 |
- if (h->version != 1 &&
|
|
|
803fb7 |
- h->version != 2)
|
|
|
803fb7 |
+ if (!IN_SET(h->version, 1, 2))
|
|
|
803fb7 |
return -EBADMSG;
|
|
|
803fb7 |
|
|
|
803fb7 |
if (h->type == _SD_BUS_MESSAGE_TYPE_INVALID)
|
|
|
803fb7 |
return -EBADMSG;
|
|
|
803fb7 |
|
|
|
803fb7 |
- if (h->endian != BUS_LITTLE_ENDIAN &&
|
|
|
803fb7 |
- h->endian != BUS_BIG_ENDIAN)
|
|
|
803fb7 |
+ if (!IN_SET(h->endian, BUS_LITTLE_ENDIAN, BUS_BIG_ENDIAN))
|
|
|
803fb7 |
return -EBADMSG;
|
|
|
803fb7 |
|
|
|
803fb7 |
/* Note that we are happy with unknown flags in the flags header! */
|
|
|
803fb7 |
@@ -557,6 +555,7 @@ int bus_message_from_header(
|
|
|
803fb7 |
|
|
|
803fb7 |
m->bus = sd_bus_ref(bus);
|
|
|
803fb7 |
*ret = m;
|
|
|
803fb7 |
+ m = NULL;
|
|
|
803fb7 |
|
|
|
803fb7 |
return 0;
|
|
|
803fb7 |
}
|