commit cfe67fbec09569d886a5cc3ea14361b05f874ebe
parent 05aaab5d8b5ed09cbfd6444fa288ee2ad6d9e879
Author: Frederic Cambus <fred@statdns.com>
Date: Wed, 31 Oct 2018 21:45:09 +0100
Free the ANSI and PCBoard buffers on error paths
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c
@@ -457,6 +457,7 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options)
if (!canvas) {
ctx->error = ANSILOVE_GD_ERROR;
+ free(ansi_buffer);
return -1;
}
@@ -519,8 +520,10 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options)
gdImageColorTransparent(canvas, 0);
// create output image
- if (output(ctx, options, canvas) != 0)
+ if (output(ctx, options, canvas) != 0) {
+ free(ansi_buffer);
return -1;
+ }
// free memory
free(ansi_buffer);
diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c
@@ -154,6 +154,7 @@ int ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options)
if (!canvas) {
ctx->error = ANSILOVE_GD_ERROR;
+ free(pcboard_buffer);
return -1;
}
@@ -187,8 +188,10 @@ int ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options)
}
// create output image
- if (output(ctx, options, canvas) != 0)
+ if (output(ctx, options, canvas) != 0) {
+ free(pcboard_buffer);
return -1;
+ }
// free memory
free(pcboard_buffer);