diff options
author | Cong Wang <1209787+congwang@users.noreply.github.com> | 2017-12-14 13:07:04 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-14 13:07:04 +0100 |
commit | f581267a021546daa0c8c9aec2c1a3107964c118 (patch) | |
tree | 0e9f6be2a4ca83f679f0005734cd73f12d4eaa46 | |
parent | Merge pull request #7606 from yuwata/run-timer (diff) | |
download | systemd-f581267a021546daa0c8c9aec2c1a3107964c118.tar.xz systemd-f581267a021546daa0c8c9aec2c1a3107964c118.zip |
sd-bus: fix a memory leak in message_new_reply() (#7636)
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 9d4ac8ee0f..219cff1f6e 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -707,6 +707,7 @@ static int message_new_reply( sd_bus_message **m) { sd_bus_message *t; + uint64_t cookie; int r; assert_return(call, -EINVAL); @@ -715,6 +716,10 @@ static int message_new_reply( assert_return(call->bus->state != BUS_UNSET, -ENOTCONN); assert_return(m, -EINVAL); + cookie = BUS_MESSAGE_COOKIE(call); + if (cookie == 0) + return -EOPNOTSUPP; + r = sd_bus_message_new(call->bus, &t, type); if (r < 0) return -ENOMEM; @@ -722,10 +727,7 @@ static int message_new_reply( assert(t); t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED; - t->reply_cookie = BUS_MESSAGE_COOKIE(call); - if (t->reply_cookie == 0) - return -EOPNOTSUPP; - + t->reply_cookie = cookie; r = message_append_reply_cookie(t, t->reply_cookie); if (r < 0) goto fail; |