Skip to content

Commit

Permalink
lib: rest_client: Fix memory leak during timeout
Browse files Browse the repository at this point in the history
This issue was pointed out by Coverity.

Signed-off-by: Tommi Rantanen <[email protected]>
  • Loading branch information
trantanen authored and anangl committed Sep 5, 2023
1 parent d2e56b7 commit 9a9e46b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions subsys/net/lib/rest_client/src/rest_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static int rest_client_sckt_connect(int *const fd,
/* Check if timeout has already elapsed */
if (time_used >= *timeout_ms) {
LOG_WRN("Timeout occurred during DNS query");
return -ETIMEDOUT;
ret = -ETIMEDOUT;
goto clean_up;
}
}

Expand Down Expand Up @@ -244,7 +245,8 @@ static int rest_client_sckt_connect(int *const fd,
/* Check if timeout has already elapsed */
if (time_used >= *timeout_ms) {
LOG_WRN("Timeout occurred during socket connect");
return -ETIMEDOUT;
ret = -ETIMEDOUT;
goto clean_up;
}
*timeout_ms -= time_used;
}
Expand Down

0 comments on commit 9a9e46b

Please sign in to comment.