From 7f4e0acf411facbcf989f8585692f8987477be23 Mon Sep 17 00:00:00 2001 From: Eemeli Kallio Date: Tue, 19 Feb 2019 13:53:42 +0200 Subject: [PATCH] Added check if max-merge is out of bounds --- src/cfg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 40660b7f..6cd9a348 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -1228,8 +1228,14 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) } else if (OPT("fast-residual-cost")) cfg->fast_residual_cost_limit = atoi(value); - else if (OPT("max-merge")) - cfg->max_merge = atoi(value); + else if (OPT("max-merge")) { + int max_merge = atoi(value); + if (max_merge < 1 || max_merge > 5) { + fprintf(stderr, "max-merge needs to be between 1 and 5\n"); + return 0; + } + cfg->max_merge = (uint8_t)max_merge; + } else { return 0; }