From 906082601d85b949c6b6cd738127ead8bb942ad1 Mon Sep 17 00:00:00 2001 From: Shuai Lin Date: Tue, 28 Jun 2016 14:09:22 +0800 Subject: [PATCH] More memory leak fixed. --- lib/searpc-named-pipe-transport.c | 4 ++++ tests/searpc.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/searpc-named-pipe-transport.c b/lib/searpc-named-pipe-transport.c index 8f47d06..ea3fc4f 100644 --- a/lib/searpc-named-pipe-transport.c +++ b/lib/searpc-named-pipe-transport.c @@ -349,14 +349,18 @@ char *searpc_named_pipe_send(void *arg, const gchar *fcall_str, uint32_t len = json_len; if (pipe_write_n(client->pipe_fd, &len, sizeof(uint32_t)) < 0) { g_warning("failed to send rpc call: %s", strerror(errno)); + free (json_str); return NULL; } if (pipe_write_n(client->pipe_fd, json_str, json_len) < 0) { g_warning("failed to send rpc call: %s", strerror(errno)); + free (json_str); return NULL; } + free (json_str); + if (pipe_read_n(client->pipe_fd, &len, sizeof(uint32_t)) < 0) { g_warning("failed to read rpc response: %s", strerror(errno)); return NULL; diff --git a/tests/searpc.c b/tests/searpc.c index 83bd87a..a293f15 100644 --- a/tests/searpc.c +++ b/tests/searpc.c @@ -228,6 +228,7 @@ test_searpc__simple_call (void) 2, "string", "hello", "int", 10); cl_assert (error->message); g_free (result); + g_error_free(error); } void @@ -240,6 +241,7 @@ test_searpc__invalid_call (void) 2, "string", "hello", "int", 2); cl_assert (error != NULL); g_free (result); + g_error_free (error); } GObject * @@ -384,6 +386,7 @@ void simple_callback_error (void *result, void *user_data, GError *error) { cl_assert (result == NULL); cl_assert (error != NULL); + g_error_free (error); } void