commit 18af8c3b004442ac6cbdd08920ec75493d9de26c
parent 169bba1abc4989fdb6b03fcf7824ea69a239c440
Author: Frederic Cambus <fred@statdns.com>
Date: Sun, 11 Oct 2020 09:27:21 +0200
Error out early with ANSILOVE_FORMAT_ERROR in case ctx->length is 0.
Diffstat:
3 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c
@@ -57,6 +57,11 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options)
return -1;
}
+ if (!ctx->length) {
+ ctx->error = ANSILOVE_FORMAT_ERROR;
+ goto error;
+ }
+
/* ladies and gentlemen, it's type declaration time */
struct fontStruct fontData;
diff --git a/src/loaders/binary.c b/src/loaders/binary.c
@@ -33,6 +33,11 @@ ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options)
return -1;
}
+ if (!ctx->length) {
+ ctx->error = ANSILOVE_FORMAT_ERROR;
+ return -1;
+ }
+
struct fontStruct fontData;
/* font selection */
diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c
@@ -47,6 +47,11 @@ ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options)
return -1;
}
+ if (!ctx->length) {
+ ctx->error = ANSILOVE_FORMAT_ERROR;
+ goto error;
+ }
+
struct fontStruct fontData;
size_t loop = 0, structIndex = 0;