Skip to content

Commit 086ff68

Browse files
maxd-nordicrlubos
authored andcommitted
lib: nrf_cloud_coap_download: fix malloc issue
Fix unchecked memory allocation. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 06f8735 commit 086ff68

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/lib/nrf_cloud/coap/src/nrf_cloud_coap_download.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ static int handle_coap_auth(int socket)
6161
uint16_t mid = sys_cpu_to_be16(coap_next_id());
6262
size_t request_size;
6363

64+
if (!packet_buf) {
65+
LOG_ERR("Failed to allocate memory for CoAP auth request buffer");
66+
err = -ENOMEM;
67+
goto end;
68+
}
69+
6470
/* Make new random token */
6571
sys_rand_get(token, COAP_TOKEN_MAX_LEN);
6672

0 commit comments

Comments
 (0)