apix-spi-example: fix memory leak

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2025-06-18 15:55:12 +02:00
parent 67b6d9ed60
commit 413a30b9c1
1 changed files with 2 additions and 0 deletions

View File

@ -281,6 +281,8 @@ static int read_page(int page_index, uint8_t* data)
read_data = (uint8_t *)calloc(page_size + OPERATION_BYTES + address_bytes, read_data = (uint8_t *)calloc(page_size + OPERATION_BYTES + address_bytes,
sizeof(uint8_t)); sizeof(uint8_t));
if (write_data == NULL || read_data == NULL) { if (write_data == NULL || read_data == NULL) {
free(write_data);
free(read_data);
printf("Unable to allocate memory to read the page."); printf("Unable to allocate memory to read the page.");
return EXIT_FAILURE; return EXIT_FAILURE;
} }