From f9d3d318f11133a9b80aa3f025e22c664f502984 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Tue, 14 Apr 2015 17:22:55 +0200 Subject: [PATCH] Fixed rare crash where the output provider does not get defined --- src/main.c | 16 +++++++--------- src/options.c | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 19c7fcd..32859c9 100644 --- a/src/main.c +++ b/src/main.c @@ -140,17 +140,15 @@ int main(int argc, char *argv[]) { textdomain (PACKAGE "-test"); #endif - criterion_options = (struct criterion_options) { - .always_succeed = !strcmp("1", getenv("CRITERION_ALWAYS_SUCCEED") ?: "0"), - .no_early_exit = !strcmp("1", getenv("CRITERION_NO_EARLY_EXIT") ?: "0"), - .fail_fast = !strcmp("1", getenv("CRITERION_FAIL_FAST") ?: "0"), - .use_ascii = use_ascii, - .logging_threshold = atoi(getenv("CRITERION_VERBOSITY_LEVEL") ?: "2"), + struct criterion_options *opt = &criterion_options; + opt->always_succeed = !strcmp("1", getenv("CRITERION_ALWAYS_SUCCEED") ?: "0"); + opt->no_early_exit = !strcmp("1", getenv("CRITERION_NO_EARLY_EXIT") ?: "0"); + opt->fail_fast = !strcmp("1", getenv("CRITERION_FAIL_FAST") ?: "0"); + opt->use_ascii = use_ascii; + opt->logging_threshold = atoi(getenv("CRITERION_VERBOSITY_LEVEL") ?: "2"); #ifdef HAVE_FNMATCH - .pattern = getenv("CRITERION_TEST_PATTERN"), + opt->pattern = getenv("CRITERION_TEST_PATTERN"); #endif - .output_provider = NORMAL_LOGGING, - }; bool use_tap = !strcmp("1", getenv("CRITERION_ENABLE_TAP") ?: "0"); diff --git a/src/options.c b/src/options.c index 21fcef8..c83b294 100644 --- a/src/options.c +++ b/src/options.c @@ -25,4 +25,5 @@ struct criterion_options criterion_options = { .logging_threshold = CRITERION_IMPORTANT, + .output_provider = &normal_logging, };