libansilove

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

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

Unmap ctx->buffer on cleanup. From Joris Vink, thanks!

Diffstat:
Msrc/clean.c | 7+++++++
Msrc/init.c | 4++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/clean.c b/src/clean.c @@ -10,6 +10,8 @@ * See LICENSE file for details. */ +#include <sys/mman.h> + #include <stddef.h> #include "ansilove.h" #include "gd.h" @@ -21,6 +23,11 @@ ansilove_clean(struct ansilove_ctx *ctx) { if (ctx->png.buffer != NULL) gdFree(ctx->png.buffer); + + if (ctx->buffer != MAP_FAILED) + (void)munmap(ctx->buffer, ctx->maplen); + + ctx->maplen = ctx->length = 0; ctx->png.length = 0; return 0; diff --git a/src/init.c b/src/init.c @@ -10,6 +10,8 @@ * See LICENSE file for details. */ +#include <sys/mman.h> + #include <string.h> #include "ansilove.h" @@ -25,6 +27,8 @@ ansilove_init(struct ansilove_ctx *ctx, struct ansilove_options *options) { memset(ctx, 0, sizeof(*ctx)); memset(options, 0, sizeof(*options)); + ctx->buffer = MAP_FAILED; + /* default to 8 if bits option is not specified */ options->bits = 8;