summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/relay/api/remote/relay-remote-network.c3
-rw-r--r--src/plugins/relay/relay-http.c3
-rw-r--r--tests/unit/plugins/relay/test-relay-http.cpp3
3 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/relay/api/remote/relay-remote-network.c b/src/plugins/relay/api/remote/relay-remote-network.c
index 3e9fbd583..0a0b8ed6a 100644
--- a/src/plugins/relay/api/remote/relay-remote-network.c
+++ b/src/plugins/relay/api/remote/relay-remote-network.c
@@ -227,8 +227,7 @@ error:
(msg_resp_error) ? " (" : "",
(msg_resp_error) ? msg_resp_error : "",
(msg_resp_error) ? ")" : "");
- if (http_resp)
- relay_http_response_free (http_resp);
+ relay_http_response_free (http_resp);
return 0;
}
diff --git a/src/plugins/relay/relay-http.c b/src/plugins/relay/relay-http.c
index 62dfb839c..aff6a1ac7 100644
--- a/src/plugins/relay/relay-http.c
+++ b/src/plugins/relay/relay-http.c
@@ -1579,6 +1579,9 @@ relay_http_parse_response (const char *data)
void
relay_http_response_free (struct t_relay_http_response *response)
{
+ if (!response)
+ return;
+
free (response->http_version);
free (response->message);
weechat_hashtable_free (response->headers);
diff --git a/tests/unit/plugins/relay/test-relay-http.cpp b/tests/unit/plugins/relay/test-relay-http.cpp
index 17254a051..7e1831b19 100644
--- a/tests/unit/plugins/relay/test-relay-http.cpp
+++ b/tests/unit/plugins/relay/test-relay-http.cpp
@@ -1041,6 +1041,9 @@ TEST(RelayHttp, ResponseAllocFree)
POINTERS_EQUAL(NULL, response->body);
relay_http_response_free (response);
+
+ /* test free of NULL response */
+ relay_http_response_free (NULL);
}
/*