Add guards for grib_is_missing_string

This commit is contained in:
Shahram Najm 2021-09-19 13:16:52 +01:00
parent e337247173
commit b26d806ea2
3 changed files with 5 additions and 2 deletions

View File

@ -603,7 +603,7 @@ static int get_native_type(grib_accessor* a)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = GRIB_TYPE_DOUBLE;
DebugAssert(self);
switch (self->type) {
case BUFR_DESCRIPTOR_TYPE_STRING:
ret = GRIB_TYPE_STRING;

View File

@ -314,6 +314,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha
char long_format[] = "%ld"; /* default format for printing integer keys */
char default_separator[] = " ";
grib_accessor* a = al->accessor;
DebugAssert(a);
/* Number of columns specified as 0 means print on ONE line i.e. num cols = infinity */
if (maxcols == 0)

View File

@ -599,7 +599,9 @@ int grib_is_missing_string(grib_accessor* a, unsigned char* x, size_t len)
}
}
ret = (a == NULL || ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && ret == 1)) ? 1 : 0;
if (!a) return ret;
ret = ( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && ret == 1) ) ? 1 : 0;
return ret;
}