ECC-1926: GRIB2: Incorrect decoding of data values when packingType=grid_complex_spatial_differencing

This commit is contained in:
shahramn 2024-09-27 16:35:39 +01:00
parent a14888bf97
commit 8473df1df8
1 changed files with 9 additions and 1 deletions

View File

@ -1464,7 +1464,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c
} }
template <typename T> template <typename T>
static int unpack(grib_accessor* a, T* val, const size_t* len) static int unpack(grib_accessor* a, T* val, size_t* len)
{ {
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers"); static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
grib_accessor_data_g22order_packing_t* self = reinterpret_cast<grib_accessor_data_g22order_packing_t*>(a); grib_accessor_data_g22order_packing_t* self = reinterpret_cast<grib_accessor_data_g22order_packing_t*>(a);
@ -1566,6 +1566,14 @@ static int unpack(grib_accessor* a, T* val, const size_t* len)
self->dirty = 0; self->dirty = 0;
if (bits_per_value == 0) {
for (i = 0; i < n_vals; i++) {
val[i] = reference_value;
}
*len = n_vals;
return GRIB_SUCCESS;
}
sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long));
if (!sec_val) return GRIB_OUT_OF_MEMORY; if (!sec_val) return GRIB_OUT_OF_MEMORY;
memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718