libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit 988c668a43b3e05a4d555c7d97b6cf0105e3cdfc
parent 9b3c202d23893aa532494044fdd1713c9a8351d9
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 22 Jan 2019 12:24:48 +0100

Use the correct idiom for realloc in the IDF loader as well.

Diffstat:
Msrc/loaders/icedraw.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -49,7 +49,7 @@ ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) uint32_t idf_sequence_length, idf_sequence_loop, i = 0; /* dynamically allocated memory buffer for IDF data */ - uint8_t *idf_buffer; + uint8_t *ptr, *idf_buffer; idf_buffer = malloc(2); uint16_t idf_data, idf_data_length; @@ -66,12 +66,13 @@ ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) for (idf_sequence_loop = 0; idf_sequence_loop < idf_sequence_length; idf_sequence_loop++) { /* reallocate IDF buffer memory */ - idf_buffer = realloc(idf_buffer, i + 2); - if (idf_buffer == NULL) { + ptr = realloc(idf_buffer, i + 2); + if (ptr == NULL) { ctx->error = ANSILOVE_MEMORY_ERROR; free(idf_buffer); - idf_buffer = NULL; return -1; + } else { + idf_buffer = ptr; } idf_buffer[i] = ctx->buffer[loop + 4];