GRIB-962: grib_get_data does not fail when it cannot decode the data

This commit is contained in:
Shahram Najm 2016-04-07 10:53:10 +01:00
parent b479ed65d0
commit 1f64d2020f
1 changed files with 10 additions and 4 deletions

View File

@ -116,7 +116,12 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
while(grib_iterator_next(iter,lat++,lon++,val++)) {} while(grib_iterator_next(iter,lat++,lon++,val++)) {}
} else if (err==GRIB_NOT_IMPLEMENTED || err==GRIB_SUCCESS){ } else if (err==GRIB_NOT_IMPLEMENTED || err==GRIB_SUCCESS){
size=numberOfPoints; size=numberOfPoints;
grib_get_double_array(h,"values",data_values,&size); err = grib_get_double_array(h,"values",data_values,&size);
if (err) {
grib_context_log(h->context,GRIB_LOG_ERROR,"Cannot decode values: %s",
grib_get_error_message(err));
exit(1);
}
if (size!=numberOfPoints) { if (size!=numberOfPoints) {
if (!grib_options_on("q")) if (!grib_options_on("q"))
fprintf(dump_file,"ERROR: wrong number of points %d\n",(int)numberOfPoints); fprintf(dump_file,"ERROR: wrong number of points %d\n",(int)numberOfPoints);
@ -279,8 +284,9 @@ static grib_values* get_key_values(grib_runtime_options* options,grib_handle* h)
} }
int grib_no_handle_action(int err) { int grib_no_handle_action(int err)
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n"); {
return 0; fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
} }