From 89ce9f09e28f0a07694ce12f4bf331f8ddc8e539 Mon Sep 17 00:00:00 2001 From: Ciara Power Date: Tue, 13 Oct 2020 16:56:48 +0100 Subject: [PATCH] test/telemetry: fix socket resource leak If an error occurred when reading from the socket, the function returned without closing the socket. This is now fixed to avoid the resource leak of the sock variable going out of scope. Coverity issue: 363043 Fixes: bd78cf693ebd ("test/telemetry: add unit tests for data to JSON") Signed-off-by: Ciara Power Acked-by: Kevin Laatz --- app/test/test_telemetry_data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index 00326867b6..f34d691265 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -330,6 +330,7 @@ connect_to_socket(void) if (bytes < 0) { printf("%s: Error with socket read - %s\n", __func__, strerror(errno)); + close(sock); return -1; } buf[bytes] = '\0'; -- 2.20.1