mirror of https://github.com/ecmwf/eccodes.git
ECC-1494: Segmentation fault: 'grib_ls -p values' on several test GRIBs
This commit is contained in:
parent
9fe0b53373
commit
418ec30086
|
@ -409,6 +409,9 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (*len < (size_t)numberOfValues)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
if ((ret = grib_get_long_internal(handle, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -260,6 +260,9 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len)
|
|||
&numberOfSecondOrderPackedValues)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (*len < (size_t)numberOfSecondOrderPackedValues)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups);
|
||||
groupWidthsSize = numberOfGroups;
|
||||
if ((ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS)
|
||||
|
|
|
@ -411,6 +411,9 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len)
|
|||
for (i = 0; i < numberOfGroups; i++)
|
||||
n += numbersPerRow[i];
|
||||
|
||||
if (*len < (size_t)n)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * n);
|
||||
n = 0;
|
||||
k = 0;
|
||||
|
|
|
@ -501,6 +501,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if (*len < (size_t)n_vals)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS)
|
||||
|
|
Loading…
Reference in New Issue