ECC-758: GRIB1: grib_dump -j crashes

This commit is contained in:
Shahram Najm 2018-10-19 14:29:47 +01:00
parent 4208e09027
commit 05c16a0b4e
3 changed files with 125 additions and 47 deletions

View File

@ -164,7 +164,6 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len){
#endif
}
static int unpack_string(grib_accessor* a, char* val, size_t *len)
{
grib_accessor_mars_param* self = (grib_accessor_mars_param*)a;
@ -197,6 +196,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
/*if (table==200) table=128;*/
sprintf(val,"%ld.%ld",param,table);
*len = strlen(val)+1;
return GRIB_SUCCESS;
}
@ -205,4 +205,3 @@ static size_t string_length(grib_accessor* a)
{
return 7;
}

View File

@ -140,6 +140,7 @@ list( APPEND tests_data_reqd
read_any
grib_dump
grib_dump_debug
grib_dump_json
grib_local_MeteoFrance
grib_neg_fctime
codes_split_file

78
tests/grib_dump_json.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/sh
# Copyright 2005-2018 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.sh
REDIRECT=/dev/null
if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
unset ECCODES_SAMPLES_PATH
fi
files="
constant_field.grib1
lfpw.grib1
missing_field.grib1
reduced_gaussian_lsm.grib1
reduced_gaussian_model_level.grib1
reduced_gaussian_pressure_level.grib1
reduced_gaussian_pressure_level_constant.grib1
reduced_gaussian_sub_area.grib1
reduced_gaussian_surface.grib1
reduced_latlon_surface.grib1
reduced_latlon_surface_constant.grib1
reference_ensemble_mean.grib1
reference_stdev.grib1
regular_gaussian_model_level.grib1
regular_gaussian_pressure_level.grib1
regular_gaussian_pressure_level_constant.grib1
regular_gaussian_surface.grib1
regular_latlon_surface.grib1
regular_latlon_surface_constant.grib1
second_ord_rbr.grib1
small_ensemble.grib1
spectral_complex.grib1
spherical_model_level.grib1
spherical_pressure_level.grib1
constant_field.grib2
gfs.c255.grib2
jpeg.grib2
missing.grib2
multi.grib2
multi_created.grib2
reduced_gaussian_model_level.grib2
reduced_gaussian_pressure_level.grib2
reduced_gaussian_pressure_level_constant.grib2
reduced_gaussian_sub_area.grib2
reduced_gaussian_surface.grib2
reduced_gaussian_surface_jpeg.grib2
reduced_latlon_surface.grib2
reduced_latlon_surface_constant.grib2
regular_gaussian_model_level.grib2
regular_gaussian_pressure_level.grib2
regular_gaussian_pressure_level_constant.grib2
regular_gaussian_surface.grib2
regular_latlon_surface.grib2
regular_latlon_surface_constant.grib2
sample.grib2
spherical_model_level.grib2
spherical_pressure_level.grib2
test_uuid.grib2
tigge_af_ecmwf.grib2
tigge_cf_ecmwf.grib2
v.grib2
"
for file in $files; do
if [ -f ${data_dir}/$file ]; then
${tools_dir}/grib_dump -j ${data_dir}/$file 2> $REDIRECT > $REDIRECT
fi
done