libansilove

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

commit 00ef8b349d6c62c54d9b67e5d7ba7926c679d416
parent 1142259bc23671d17a50f4fc366a18693fbe1744
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu, 22 Nov 2018 14:09:13 +0100

Avoid using seqValue uninitialized

Diffstat:
Msrc/loaders/ansi.c | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -380,23 +380,24 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop); seqTok = strtok(seqGrab, ";"); - if (seqTok) + if (seqTok) { seqValue = strtonum(seqTok, 0, UCHAR_MAX, &errstr); - seqTok = strtok(NULL, ";"); - color_R = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; - seqTok = strtok(NULL, ";"); - color_G = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; - seqTok = strtok(NULL, ";"); - color_B = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; + seqTok = strtok(NULL, ";"); + color_R = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; + seqTok = strtok(NULL, ";"); + color_G = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; + seqTok = strtok(NULL, ";"); + color_B = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; - if (seqValue == 0) - background = (color_R << 16) | (color_G << 8) | color_B; + if (seqValue == 0) + background = (color_R << 16) | (color_G << 8) | color_B; - if (seqValue == 1) - foreground = (color_R << 16) | (color_G << 8) | color_B; + if (seqValue == 1) + foreground = (color_R << 16) | (color_G << 8) | color_B; - options->truecolor = true; + options->truecolor = true; + } loop += ansi_sequence_loop+2; free(seqGrab);