gbaconv

A set of tools aimed at GameBoy Advance developers
Log | Files | Refs | README | LICENSE

commit 45a912766e4548cf70e75b6f448701484c9b3938
parent 4e709af3213fc30aafe24412807ad5a09d821be9
Author: Frederic Cambus <fred@statdns.com>
Date:   Sun, 18 Oct 2020 17:26:25 +0200

Check malloc() return value and error out on failed allocations.

Diffstat:
Mpcx2gba.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/pcx2gba.c b/pcx2gba.c @@ -115,6 +115,11 @@ int main(int argc, char *argv[]) pcx_buffer_size = pcx_header.x_max * pcx_header.y_max; pcx_buffer = malloc(pcx_buffer_size); + if (!pcx_buffer) { + printf("ERROR: Cannot allocate memory for the PCX buffer\n\n"); + return EXIT_FAILURE; + } + loop = PCX_HEADER_LENGTH; while (loop < st.st_size - PCX_PALETTE_LENGTH) {