libansilove

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

commit dce0a8f7aa66846b68bd2bfad24dab6fa7ccd776
parent 32b00174a97e6f992c952232d69928886e19f2fd
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu,  1 Nov 2018 08:12:21 +0100

Modify the strtok while loop for SGR sequences to avoid leaking memory

Diffstat:
Msrc/loaders/ansi.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -299,7 +299,8 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) /* create substring from the sequence's content */ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop); - while ((seqTok = strtok(seqGrab, ";")) != NULL) { + seqTok = strtok(seqGrab, ";"); + while (seqTok) { seqValue = strtonum(seqTok, 0, UINT32_MAX, &errstr); if (seqValue == 0) { @@ -347,7 +348,7 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) background += 8; } - seqGrab = NULL; + seqTok = strtok(NULL, ";"); } loop += ansi_sequence_loop+2;