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 <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2024-10-17 14:42:39 +02:00 committed by Alberto Escolar
parent 6d4031f96c
commit 2d0e7bc7d5

View file

@ -76,14 +76,14 @@ static int echo_handler(struct http_client_ctx *client, enum http_data_status st
enum http_method method = client->method;
static size_t processed;
__ASSERT_NO_MSG(buffer != NULL);
if (status == HTTP_SERVER_DATA_ABORTED) {
LOG_DBG("Transaction aborted after %zd bytes.", processed);
processed = 0;
return 0;
}
__ASSERT_NO_MSG(buffer != NULL);
processed += len;
snprintf(print_str, sizeof(print_str), "%s received (%zd bytes)",