test/telemetry: fix socket resource leak
PATCH 1/1 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
--- app/test/test_telemetry_data.c | 1 + 1 file changed, 1 insertion(+)
app/test/test_telemetry_data.c +1 -0
@@ -327,6 +327,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' ;
Signature · 1 line
2.22.0
Quoted 17 lines · Ciara Power
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.
Fixes bd78cf693ebd ("test/telemetry: add unit tests for data to JSON")Coverity issue: 363043
Signed-off-by Ciara Power <[email protected]>--- app/test/test_telemetry_data.c | 1 + 1 file changed, 1 insertion(+)app/test/test_telemetry_data.c +0
-0
app/test/test_telemetry_data.c connect_to_socket(void) · line 333
Quoted 7 lines
app/test/test_telemetry_data.c +1
-0@@ -327,6 +327,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' ;
Thomas Monjalon
Applied15/10/2020 19:02, Kevin Laatz:
Quoted 11 lines · Ciara Power
Quoted 8 lines
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.
Fixes bd78cf693ebd ("test/telemetry: add unit tests for data to JSON")Coverity issue: 363043
Signed-off-by Ciara Power <[email protected]>Acked-by Kevin Laatz <[email protected]>
Applied, thanks