diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-01-09 09:04:18 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-01-09 10:15:12 +1100 |
commit | 6a36799d30c1bfb685ccfe77257433710f23215c (patch) | |
tree | 5f56584bf23c35ecbdd635223c88a3c08ff0e5eb /source4/lib | |
parent | 196cb6b359f3a8cdca5e1d4bb17a7ab7897095ab (diff) | |
download | samba-6a36799d30c1bfb685ccfe77257433710f23215c.tar.gz samba-6a36799d30c1bfb685ccfe77257433710f23215c.tar.bz2 samba-6a36799d30c1bfb685ccfe77257433710f23215c.zip |
s4-messaging: fixed a memory leak in messaging_path()
It is a bit convoluted to fix, as cluster_id_string() may return a
const string.
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/messaging/messaging.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 277688e8b6..d4dfff7c8c 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -119,8 +119,15 @@ static NTSTATUS irpc_uptime(struct irpc_message *msg, */ static char *messaging_path(struct messaging_context *msg, struct server_id server_id) { - return talloc_asprintf(msg, "%s/msg.%s", msg->base_path, - cluster_id_string(msg, server_id)); + TALLOC_CTX *tmp_ctx = talloc_new(msg); + const char *id = cluster_id_string(tmp_ctx, server_id); + char *s; + if (id == NULL) { + return NULL; + } + s = talloc_asprintf(msg, "%s/msg.%s", msg->base_path, id); + talloc_steal(s, tmp_ctx); + return s; } /* |