libansilove

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

commit 5dc6297a5952836e3e5f8465488dbbaa281f15bb
parent bd98f066fa392005d8d9ff6f835cf3610101f054
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 16 Nov 2018 12:03:59 +0100

Introduce a maplen variable to allow tracking mmap size, as we can't rely on the length variable because of SAUCE

Diffstat:
Minclude/ansilove.h | 1+
Msrc/loadfile.c | 4++--
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/ansilove.h b/include/ansilove.h @@ -72,6 +72,7 @@ struct ansilove_png { struct ansilove_ctx { uint8_t *buffer; + size_t maplen; size_t length; struct ansilove_png png; uint8_t error; diff --git a/src/loadfile.c b/src/loadfile.c @@ -41,10 +41,10 @@ ansilove_loadfile(struct ansilove_ctx *ctx, char *input) { return -1; } - ctx->length = st.st_size; + ctx->maplen = ctx->length = st.st_size; /* mmap input file into memory */ - ctx->buffer = mmap(NULL, ctx->length, PROT_READ, MAP_PRIVATE, fd, 0); + ctx->buffer = mmap(NULL, ctx->maplen, PROT_READ, MAP_PRIVATE, fd, 0); if (ctx->buffer == MAP_FAILED) { ctx->error = ANSILOVE_MEMORY_ERROR; close(fd);