ECC-1605: Fix lower bound

This commit is contained in:
Shahram Najm 2023-06-02 17:48:32 +01:00
parent 9cbeff4549
commit 8169b17ca8
2 changed files with 2 additions and 2 deletions

View File

@ -228,7 +228,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
} else {
// ECC-1605: Check overflow/underflow
const int nbits = self->nbytes * 8;
const long minval = -(1L << (nbits-1));
const long minval = -(1L << (nbits-1)) + 1;
const long maxval = (1L << (nbits-1)) - 1;
//printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval);
if (v > maxval || v < minval) {

View File

@ -84,7 +84,7 @@ if [ $ECCODES_ON_WINDOWS -eq 0 ]; then
status=$?
set -e
[ $status -ne 0 ]
grep -q "Trying to encode value of 2147483648 but the allowable range is -2147483648 to 2147483647" $temp
grep -q "Trying to encode value of 2147483648 but the allowable range is -2147483647 to 2147483647" $temp
set +e
${tools_dir}/grib_set -s forecastTime=-2147483650 $input $outfile 2>$temp