1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

libdaemon-client: Fix a memory leak in daemon_send.

This commit is contained in:
Petr Rockai 2012-10-08 18:35:30 +02:00
parent 4b4c2833d9
commit a19a595343

View File

@ -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;
}