Hello community, here is the log from the commit of package libansilove for openSUSE:Factory checked in at 2020-09-27 11:50:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libansilove (Old) and /work/SRC/openSUSE:Factory/.libansilove.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libansilove" Sun Sep 27 11:50:24 2020 rev:10 rq:837817 version:1.2.5 Changes: -------- --- /work/SRC/openSUSE:Factory/libansilove/libansilove.changes 2020-06-22 17:47:00.866055649 +0200 +++ /work/SRC/openSUSE:Factory/.libansilove.new.4249/libansilove.changes 2020-09-27 11:50:24.908084728 +0200 @@ -1,0 +2,17 @@ +Thu Sep 24 18:38:11 UTC 2020 - Martin Hauke <mar...@gmx.de> + +- Update to version 1.2.5 + * Add missing parentheses in an if statement in output() + * Define CR, LF, TAB, SUB, and ESC macros only once + * Refactor error handling in the PCBoard loader + * Stop parsing for PCBoard cursor position sequences + * Add bound checks for {back,fore}ground color values in the + PCBoard loader + * Fix default background and foreground colors in the PCBoard + loader + * Refactor the PCBoard loader to use a state machine + * Refactor the Binary loader to use a state machine + * Refactor the Artworx loader to use a state machine + * Add some file format integrity checks in the XBin loader + +------------------------------------------------------------------- Old: ---- libansilove-1.2.4.tar.gz New: ---- libansilove-1.2.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libansilove.spec ++++++ --- /var/tmp/diff_new_pack.AKAmed/_old 2020-09-27 11:50:25.644085521 +0200 +++ /var/tmp/diff_new_pack.AKAmed/_new 2020-09-27 11:50:25.648085526 +0200 @@ -2,7 +2,7 @@ # spec file for package libansilove # # Copyright (c) 2020 SUSE LLC -# Copyright (c) 2019, Martin Hauke <mar...@gmx.de> +# Copyright (c) 2019-2020, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ %global sover 1 %global libname %{name}%{sover} Name: libansilove -Version: 1.2.4 +Version: 1.2.5 Release: 0 Summary: Library for converting ANSI, ASCII, and other formats to PNG License: BSD-2-Clause ++++++ libansilove-1.2.4.tar.gz -> libansilove-1.2.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/.travis.yml new/libansilove-1.2.5/.travis.yml --- old/libansilove-1.2.4/.travis.yml 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/.travis.yml 2020-09-24 11:30:38.000000000 +0200 @@ -31,7 +31,7 @@ coverity_scan: project: name: "ansilove/libansilove" - version: 1.2.4 + version: 1.2.5 description: "Library for converting ANSI, ASCII, and other formats to PNG" notification_email: f...@statdns.com build_command_prepend: cmake . diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/CMakeLists.txt new/libansilove-1.2.5/CMakeLists.txt --- old/libansilove-1.2.4/CMakeLists.txt 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/CMakeLists.txt 2020-09-24 11:30:38.000000000 +0200 @@ -2,7 +2,7 @@ set(LIB_VERSION_MAJOR 1) set(LIB_VERSION_MINOR 2) -set(LIB_VERSION_PATCH 4) +set(LIB_VERSION_PATCH 5) set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}) project (ansilove C) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/ChangeLog new/libansilove-1.2.5/ChangeLog --- old/libansilove-1.2.4/ChangeLog 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/ChangeLog 2020-09-24 11:30:38.000000000 +0200 @@ -1,3 +1,18 @@ +libansilove 1.2.5 (2020-09-24) + +- Add missing parentheses in an if statement in output() +- Define CR, LF, TAB, SUB, and ESC macros only once +- Refactor error handling in the PCBoard loader +- Stop parsing for PCBoard cursor position sequences +- Add bound checks for {back,fore}ground color values in the PCBoard loader +- Fix default background and foreground colors in the PCBoard loader +- Refactor the PCBoard loader to use a state machine +- Refactor the Binary loader to use a state machine +- Refactor the Artworx loader to use a state machine +- Add some file format integrity checks in the XBin loader + + + libansilove 1.2.4 (2020-06-21) - Use size_t in for loops setting color palettes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/README.md new/libansilove-1.2.5/README.md --- old/libansilove-1.2.4/README.md 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/README.md 2020-09-24 11:30:38.000000000 +0200 @@ -18,7 +18,7 @@ - Mac OS X: `brew install cmake gd` - Alpine Linux: `apk add cmake gcc make musl-dev gd-dev` - Debian / Ubuntu / Mint: `apt-get install build-essential cmake libgd-dev` -- Fedora: `yum install cmake gcc make gd-devel` +- Fedora: `dnf install cmake gcc make gd-devel` - Solus: `eopkg install -c system.devel` and `eopkg install gd-devel` # Compiling diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/include/ansilove.h new/libansilove-1.2.5/include/ansilove.h --- old/libansilove-1.2.4/include/ansilove.h 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/include/ansilove.h 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * ansilove.h - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -20,11 +20,11 @@ #define ANSILOVE_EXTERN __attribute__((visibility("default"))) /* Version number */ -#define ANSILOVE_VERSION "1.2.4" +#define ANSILOVE_VERSION "1.2.5" #define ANSILOVE_VERSION_MAJOR 1 #define ANSILOVE_VERSION_MINOR 2 -#define ANSILOVE_VERSION_PATCH 4 +#define ANSILOVE_VERSION_PATCH 5 /* Error codes */ #define ANSILOVE_INVALID_PARAM 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/clean.c new/libansilove-1.2.5/src/clean.c --- old/libansilove-1.2.4/src/clean.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/clean.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * clean.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/config.h new/libansilove-1.2.5/src/config.h --- old/libansilove-1.2.4/src/config.h 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/config.h 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * config.h - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -15,6 +15,14 @@ #include <stdint.h> +#define LF '\n' +#define CR '\r' +#define TAB '\t' +#define SUB 26 +#define ESC 27 + +#define PCB_COLORS 71 + static const uint8_t ansi_palette_red[] = { 0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff @@ -63,7 +71,7 @@ /* ADF color mapping array */ static const uint8_t adf_colors[16] = { 0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63 }; -static const uint8_t pcb_colors[] = { +static const uint8_t pcb_colors[PCB_COLORS] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/drawchar.c new/libansilove-1.2.5/src/drawchar.c --- old/libansilove-1.2.4/src/drawchar.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/drawchar.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * drawchar.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/drawchar.h new/libansilove-1.2.5/src/drawchar.h --- old/libansilove-1.2.4/src/drawchar.h 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/drawchar.h 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * drawchar.h - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/error.c new/libansilove-1.2.5/src/error.c --- old/libansilove-1.2.4/src/error.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/error.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * error.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/fonts.c new/libansilove-1.2.5/src/fonts.c --- old/libansilove-1.2.4/src/fonts.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/fonts.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * fonts.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/fonts.h new/libansilove-1.2.5/src/fonts.h --- old/libansilove-1.2.4/src/fonts.h 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/fonts.h 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * fonts.h - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/init.c new/libansilove-1.2.5/src/init.c --- old/libansilove-1.2.4/src/init.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/init.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * init.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/ansi.c new/libansilove-1.2.5/src/loaders/ansi.c --- old/libansilove-1.2.4/src/loaders/ansi.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/ansi.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * ansi.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -30,12 +30,6 @@ #define ANSI_SEQUENCE_MAX_LENGTH 14 #define ANSI_BUFFER_SIZE 65536 -#define LF '\n' -#define CR '\r' -#define TAB '\t' -#define SUB 26 -#define ESC 27 - /* Character structure */ struct ansiChar { int32_t column; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/artworx.c new/libansilove-1.2.5/src/loaders/artworx.c --- old/libansilove-1.2.4/src/loaders/artworx.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/artworx.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * artworx.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -20,6 +20,9 @@ #define ADF_HEADER_LENGTH 4289 /* 192 + 4096 + 1 */ +#define STATE_CHARACTER 0 +#define STATE_ATTRIBUTE 1 + int ansilove_artworx(struct ansilove_ctx *ctx, struct ansilove_options *options) { @@ -39,7 +42,9 @@ gdImagePtr canvas; /* create ADF instance */ - canvas = gdImageCreate(640, (((ctx->length - ADF_HEADER_LENGTH) / 2) / 80) * 16); + canvas = + gdImageCreate(640, (ctx->length - ADF_HEADER_LENGTH) / 2 / 80 * 16); + if (!canvas) { ctx->error = ANSILOVE_GD_ERROR; return -1; @@ -50,32 +55,47 @@ /* process ADF palette */ for (loop = 0; loop < 16; loop++) { index = (adf_colors[loop] * 3) + 1; - gdImageColorAllocate(canvas, (ctx->buffer[index] << 2 | ctx->buffer[index] >> 4), - (ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4), - (ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4)); + gdImageColorAllocate(canvas, + ctx->buffer[index] << 2 | ctx->buffer[index] >> 4, + ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4, + ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4); } /* process ADF */ + uint8_t character, attribute, *cursor, state = STATE_CHARACTER; uint32_t column = 0, row = 0; - uint32_t character, attribute, foreground, background; + uint32_t foreground, background; loop = ADF_HEADER_LENGTH; while (loop < ctx->length) { + cursor = &ctx->buffer[loop]; + if (column == 80) { column = 0; row++; } - character = ctx->buffer[loop]; - attribute = ctx->buffer[loop+1]; + switch (state) { + case STATE_CHARACTER: + character = *cursor; + state = STATE_ATTRIBUTE; + break; + case STATE_ATTRIBUTE: + attribute = *cursor; + + background = (attribute & 240) >> 4; + foreground = attribute & 15; - background = (attribute & 240) >> 4; - foreground = attribute & 15; + drawchar(canvas, ctx->buffer+193, 8, 16, column, row, + background, foreground, character); - drawchar(canvas, ctx->buffer+193, 8, 16, column, row, background, foreground, character); + column++; + + state = STATE_CHARACTER; + break; + } - column++; - loop += 2; + loop++; } /* create output file */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/binary.c new/libansilove-1.2.5/src/loaders/binary.c --- old/libansilove-1.2.4/src/loaders/binary.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/binary.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * binary.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -20,6 +20,9 @@ #include "fonts.h" #include "output.h" +#define STATE_CHARACTER 0 +#define STATE_ATTRIBUTE 1 + int ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) { @@ -44,7 +47,7 @@ /* allocate buffer image memory */ canvas = gdImageCreate(options->columns * options->bits, - ((ctx->length / 2) / options->columns * fontData.height)); + (ctx->length / 2) / options->columns * fontData.height); if (!canvas) { ctx->error = ANSILOVE_GD_ERROR; @@ -60,23 +63,29 @@ } /* process binary */ - uint32_t character, attribute, background, foreground; + uint8_t character, attribute, *cursor, state = STATE_CHARACTER; + uint32_t background, foreground; size_t loop = 0; int32_t column = 0, row = 0; while (loop < ctx->length) { + cursor = &ctx->buffer[loop]; + if (column == options->columns) { column = 0; row++; } - character = ctx->buffer[loop]; - - if (ctx->length > loop) { - attribute = ctx->buffer[loop+1]; + switch (state) { + case STATE_CHARACTER: + character = *cursor; + state = STATE_ATTRIBUTE; + break; + case STATE_ATTRIBUTE: + attribute = *cursor; background = (attribute & 240) >> 4; - foreground = (attribute & 15); + foreground = attribute & 15; if (background > 8 && !options->icecolors) background -= 8; @@ -86,8 +95,12 @@ colors[foreground], character); column++; - loop += 2; + + state = STATE_CHARACTER; + break; } + + loop++; } /* create output image */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/icedraw.c new/libansilove-1.2.5/src/loaders/icedraw.c --- old/libansilove-1.2.4/src/loaders/icedraw.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/icedraw.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * icedraw.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/pcboard.c new/libansilove-1.2.5/src/loaders/pcboard.c --- old/libansilove-1.2.4/src/loaders/pcboard.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/pcboard.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * pcboard.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -20,10 +20,9 @@ #include "fonts.h" #include "output.h" -#define LF '\n' -#define CR '\r' -#define TAB '\t' -#define SUB 26 +#define STATE_TEXT 0 +#define STATE_SEQUENCE 1 +#define STATE_END 2 /* Character structure */ struct pcbChar { @@ -57,8 +56,8 @@ /* libgd image pointers */ gdImagePtr canvas; - uint8_t character, *cursor; - uint32_t background = 0, foreground = 7; + uint8_t character, *cursor, state = STATE_TEXT; + uint32_t background = '0', foreground = '7'; uint32_t column = 0, row = 0, rowMax = 0; /* PCB buffer structure array definition */ @@ -75,29 +74,69 @@ column = 0; } - switch (*cursor) { - case LF: - row++; - column = 0; - break; - case CR: - break; - case TAB: - column += 8; - break; - case SUB: - loop = ctx->length; + switch (state) { + case STATE_TEXT: + switch (*cursor) { + case LF: + row++; + column = 0; + break; + case CR: + break; + case TAB: + column += 8; + break; + case SUB: + state = STATE_END; + break; + case '@': + /* PCB sequence */ + state = STATE_SEQUENCE; + break; + default: + /* record number of lines used */ + if (row > rowMax) + rowMax = row; + + /* reallocate structure array memory */ + ptr = realloc(pcboard_buffer, (structIndex + 1) * sizeof (struct pcbChar)); + if (ptr == NULL) { + ctx->error = ANSILOVE_MEMORY_ERROR; + goto error; + } else { + pcboard_buffer = ptr; + } + + /* write current character in pcbChar structure */ + pcboard_buffer[structIndex].column = column; + pcboard_buffer[structIndex].row = row; + pcboard_buffer[structIndex].background = pcb_colors[background]; + pcboard_buffer[structIndex].foreground = pcb_colors[foreground]; + pcboard_buffer[structIndex].character = *cursor; + + column++; + structIndex++; + }; + loop++; break; - case '@': - /* PCB sequence */ - if (*++cursor == 'X') { + case STATE_SEQUENCE: + if (*cursor == 'X') { /* set graphics rendition */ - background = ctx->buffer[loop+2]; - foreground = ctx->buffer[loop+3]; - loop += 3; + if (loop + 2 < ctx->length) { + background = *++cursor; + foreground = *++cursor; + + loop += 3; + } + + if (background >= PCB_COLORS || + foreground >= PCB_COLORS) { + ctx->error = ANSILOVE_FORMAT_ERROR; + goto error; + } } - if (!memcmp(cursor, "CLS", 3)) { + if (loop + 3 < ctx->length && !memcmp(cursor, "CLS@", 4)) { /* erase display */ column = 0; row = 0; @@ -110,55 +149,21 @@ loop += 4; } - if (!memcmp(cursor, "POS:", 4)) { - /* cursor position */ - if (ctx->buffer[loop+6] == '@') - { - column = ((ctx->buffer[loop+5])-48)-1; - loop += 5; - } else { - column = (10 * ((ctx->buffer[loop+5])-48) + (ctx->buffer[loop+6])-48)-1; - loop += 6; - } - } + state = STATE_TEXT; + break; + case STATE_END: + loop = ctx->length; break; - default: - /* record number of lines used */ - if (row > rowMax) - rowMax = row; - - /* reallocate structure array memory */ - ptr = realloc(pcboard_buffer, (structIndex + 1) * sizeof (struct pcbChar)); - if (ptr == NULL) { - ctx->error = ANSILOVE_MEMORY_ERROR; - free(pcboard_buffer); - return -1; - } else { - pcboard_buffer = ptr; - } - - /* write current character in pcbChar structure */ - pcboard_buffer[structIndex].column = column; - pcboard_buffer[structIndex].row = row; - pcboard_buffer[structIndex].background = pcb_colors[background]; - pcboard_buffer[structIndex].foreground = pcb_colors[foreground]; - pcboard_buffer[structIndex].character = *cursor; - - column++; - structIndex++; } - - loop++; } rowMax++; /* allocate buffer image memory */ - canvas = gdImageCreate(columns * options->bits, (rowMax)*fontData.height); + canvas = gdImageCreate(columns * options->bits, rowMax*fontData.height); if (!canvas) { ctx->error = ANSILOVE_GD_ERROR; - free(pcboard_buffer); - return -1; + goto error; } /* allocate color palette */ @@ -183,12 +188,13 @@ } /* create output image */ - if (output(ctx, options, canvas) != 0) { - free(pcboard_buffer); - return -1; - } + if (output(ctx, options, canvas) != 0) + goto error; free(pcboard_buffer); - return 0; + +error: + free(pcboard_buffer); + return -1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/tundra.c new/libansilove-1.2.5/src/loaders/tundra.c --- old/libansilove-1.2.4/src/loaders/tundra.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/tundra.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * tundra.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loaders/xbin.c new/libansilove-1.2.5/src/loaders/xbin.c --- old/libansilove-1.2.4/src/loaders/xbin.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loaders/xbin.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * xbin.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -85,9 +85,9 @@ index = (loop * 3) + offset; colors[loop] = gdImageColorAllocate(canvas, - (ctx->buffer[index] << 2 | ctx->buffer[index] >> 4), - (ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4), - (ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4)); + ctx->buffer[index] << 2 | ctx->buffer[index] >> 4, + ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4, + ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4); } offset += XBIN_PALETTE_LENGTH; @@ -132,7 +132,7 @@ /* read compressed xbin */ if ((xbin_flags & 4) == 4) { - while (offset < ctx->length && row != xbin_height) { + while (offset + 1 < ctx->length && row != xbin_height) { uint32_t ctype = ctx->buffer[offset] & 0xC0; uint32_t counter = (ctx->buffer[offset] & 0x3F) + 1; @@ -194,7 +194,7 @@ } } else { /* read uncompressed xbin */ - while (offset < ctx->length && row != xbin_height) { + while (offset + 1 < ctx->length && row != xbin_height) { if (column == xbin_width) { column = 0; row++; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/loadfile.c new/libansilove-1.2.5/src/loadfile.c --- old/libansilove-1.2.4/src/loadfile.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/loadfile.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * loadfile.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/output.c new/libansilove-1.2.5/src/output.c --- old/libansilove-1.2.4/src/output.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/output.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * output.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus @@ -39,7 +39,7 @@ if (options->scale_factor) { gdImagePtr retina; - if gdImageTrueColor(source) { + if (gdImageTrueColor(source)) { retina = gdImageCreateTrueColor(source->sx * options->scale_factor, source->sy * options->scale_factor); } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/output.h new/libansilove-1.2.5/src/output.h --- old/libansilove-1.2.4/src/output.h 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/output.h 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * output.h - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libansilove-1.2.4/src/savefile.c new/libansilove-1.2.5/src/savefile.c --- old/libansilove-1.2.4/src/savefile.c 2020-06-21 09:24:32.000000000 +0200 +++ new/libansilove-1.2.5/src/savefile.c 2020-09-24 11:30:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * savefile.c - * libansilove 1.2.4 + * libansilove 1.2.5 * https://www.ansilove.org * * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus