From 413a30b9c1db9a2b2fc6b89b7ec6368222c0e0b7 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Wed, 18 Jun 2025 15:55:12 +0200 Subject: [PATCH] apix-spi-example: fix memory leak Signed-off-by: Javier Viguera --- apix-spi-example/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apix-spi-example/main.c b/apix-spi-example/main.c index 097cd42..713c06c 100644 --- a/apix-spi-example/main.c +++ b/apix-spi-example/main.c @@ -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, sizeof(uint8_t)); if (write_data == NULL || read_data == NULL) { + free(write_data); + free(read_data); printf("Unable to allocate memory to read the page."); return EXIT_FAILURE; }