Added check if max-merge is out of bounds

This commit is contained in:
Eemeli Kallio 2019-02-19 13:53:42 +02:00
parent 2a40560888
commit 7f4e0acf41

View file

@ -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;
}