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