Memory leak in case of error

This commit is contained in:
Shahram Najm 2022-07-01 12:48:42 +01:00
parent 8c0b0ec26b
commit 2654faa154
1 changed files with 4 additions and 6 deletions

View File

@ -269,14 +269,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size);
if (!code) {
grib_context_log(a->context, GRIB_LOG_FATAL,
"unable to allocate %ld bytes", (long)size);
return GRIB_OUT_OF_MEMORY;
}
if (!code) return GRIB_OUT_OF_MEMORY;
if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS)
if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS) {
grib_context_free(a->context, code);
return err;
}
table = tableAccessor->table;