summaryrefslogtreecommitdiff
path: root/libdaemon/client
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2012-10-08 18:35:30 +0200
committerPetr Rockai <prockai@redhat.com>2012-10-08 20:35:29 +0200
commita19a5953433c86811df80c59de7ec6346c62be32 (patch)
tree4dc605dbc8763a86e981d772da5f890fabad791e /libdaemon/client
parent4b4c2833d984f6b6a8dde394168b4653cdd47863 (diff)
downloadlvm2-a19a5953433c86811df80c59de7ec6346c62be32.tar.gz
libdaemon-client: Fix a memory leak in daemon_send.
Diffstat (limited to 'libdaemon/client')
-rw-r--r--libdaemon/client/daemon-client.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index e34a2a00f..c87856c0a 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -73,12 +73,13 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
{
daemon_reply reply = { .cft = NULL, .error = 0 };
assert(h.socket_fd >= 0);
+ char *buffer = rq.buffer;
- if (!rq.buffer)
- dm_config_write_node(rq.cft->root, buffer_line, &rq.buffer);
+ if (!buffer)
+ dm_config_write_node(rq.cft->root, buffer_line, &buffer);
- assert(rq.buffer);
- if (!write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer)))
+ assert(buffer);
+ if (!write_buffer(h.socket_fd, buffer, strlen(buffer)))
reply.error = errno;
if (read_buffer(h.socket_fd, &reply.buffer)) {
@@ -88,6 +89,9 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
} else
reply.error = errno;
+ if (buffer != rq.buffer)
+ dm_free(buffer);
+
return reply;
}