GRIB-938 grib_compare: argument to '-A' (absolute error) is not checked

This commit is contained in:
Shahram Najm 2016-03-01 14:44:08 +00:00
parent cc82d59b87
commit 3c66db6e73
1 changed files with 12 additions and 2 deletions

View File

@ -258,11 +258,21 @@ int grib_tool_init(grib_runtime_options* options)
compareAbsolute=0;
}
if (grib_options_on("A:")){
const char* absTolStr = grib_options_get_option("A:");
char* endPtr = NULL; /* for error handling */
if (grib_options_on("R:")) {
maxAbsoluteError = atof(grib_options_get_option("A:"));
maxAbsoluteError = strtod(absTolStr,&endPtr);
if (*endPtr) {
fprintf(stderr, "Invalid absolute error: '%s'\n", absTolStr);
exit(1);
}
} else {
compare_double= &compare_double_absolute;
global_tolerance = atof(grib_options_get_option("A:"));
global_tolerance= strtod(absTolStr,&endPtr);
if (*endPtr) {
fprintf(stderr, "Invalid absolute error: '%s'\n", absTolStr);
exit(1);
}
}
}
if (grib_options_on("P")) {