From 58e6fb40f6b12ec89ff5faa0ad0d14f2835a5a25 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 9 Mar 2023 13:37:26 +0200 Subject: Make generator exe more resilient. --- test cases/common/105 generatorcustom/gen.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test cases') diff --git a/test cases/common/105 generatorcustom/gen.c b/test cases/common/105 generatorcustom/gen.c index 59518c0..964ae7e 100644 --- a/test cases/common/105 generatorcustom/gen.c +++ b/test cases/common/105 generatorcustom/gen.c @@ -22,9 +22,17 @@ int main(int argc, const char ** argv) { fprintf(output, "#pragma once\n"); fprintf(output, "#define "); - char c; + int bytes_copied = 0; + int c; while((c = fgetc(input)) != EOF) { - fputc(c, output); + if(fputc(c, output) == EOF) { + fprintf(stderr, "Writing to output file failed.\n"); + return 1; + } + if(++bytes_copied > 10000) { + fprintf(stderr, "File copy stuck in an eternal loop!\n"); + return 1; + } } fputc('\n', output); -- cgit v1.1