apix-spi-example: fix memory leak
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
67b6d9ed60
commit
413a30b9c1
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue