libansilove

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

commit 1aab192eee09e5cbce1804091f6ddaa4ccbf75c9
parent df40e417268e2286724fe0c29d905a9ea86e0d75
Author: Frederic Cambus <fred@statdns.com>
Date:   Mon, 28 Sep 2020 17:49:41 +0200

Switch to using reallocarray(3) in the ANSI and PCBoard loaders.

Diffstat:
Msrc/loaders/ansi.c | 2+-
Msrc/loaders/pcboard.c | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -160,7 +160,7 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) if (structIndex == ansi_buffer_size) { ansi_buffer_size += ANSI_BUFFER_SIZE; - ptr = realloc(ansi_buffer, ansi_buffer_size * sizeof(struct ansiChar)); + ptr = reallocarray(ansi_buffer, ansi_buffer_size, sizeof(struct ansiChar)); if (ptr == NULL) { ctx->error = ANSILOVE_MEMORY_ERROR; diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -99,7 +99,7 @@ ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options) rowMax = row; /* reallocate structure array memory */ - ptr = realloc(pcboard_buffer, (structIndex + 1) * sizeof (struct pcbChar)); + ptr = reallocarray(pcboard_buffer, structIndex + 1, sizeof(struct pcbChar)); if (ptr == NULL) { ctx->error = ANSILOVE_MEMORY_ERROR; goto error;