Skip to content

Commit 2d0e7bc

Browse files
rlubosaescolar
authored andcommitted
samples: net: http_server: Fix assertion on dynamic upload abort
The buffer pointer provided to the dynamic handler should be verified after checking the transaction status. In case upload was aborted and underlying connection closed, the callback will get HTTP_SERVER_DATA_ABORTED status w/o a pointer to any data. Signed-off-by: Robert Lubos <[email protected]>
1 parent 6d4031f commit 2d0e7bc

File tree

1 file changed

+2
-2
lines changed
  • samples/net/sockets/http_server/src

1 file changed

+2
-2
lines changed

samples/net/sockets/http_server/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ static int echo_handler(struct http_client_ctx *client, enum http_data_status st
7676
enum http_method method = client->method;
7777
static size_t processed;
7878

79-
__ASSERT_NO_MSG(buffer != NULL);
80-
8179
if (status == HTTP_SERVER_DATA_ABORTED) {
8280
LOG_DBG("Transaction aborted after %zd bytes.", processed);
8381
processed = 0;
8482
return 0;
8583
}
8684

85+
__ASSERT_NO_MSG(buffer != NULL);
86+
8787
processed += len;
8888

8989
snprintf(print_str, sizeof(print_str), "%s received (%zd bytes)",

0 commit comments

Comments
 (0)