Commit ff4b4fc9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gribapiGetKeys: check result of grib_get_size(gh, section2Padding, &size).

parent b85e3ac0
...@@ -456,17 +456,17 @@ void gribapiGetKeys(grib_handle *gh, int varID) ...@@ -456,17 +456,17 @@ void gribapiGetKeys(grib_handle *gh, int varID)
{ {
long grib2LocalSectionNumber; long grib2LocalSectionNumber;
grib_get_long(gh, "grib2LocalSectionNumber", &grib2LocalSectionNumber); grib_get_long(gh, "grib2LocalSectionNumber", &grib2LocalSectionNumber);
size_t size; size_t size = 0;
grib_get_size(gh, "section2Padding", &size); if ( grib_get_size(gh, "section2Padding", &size) == 0 )
if ( size > 0 ) if ( size > 0 )
{ {
varDefKeyInt(varID, CDI_KEY_GRIB2LOCALSECTIONNUMBER, (int) grib2LocalSectionNumber); varDefKeyInt(varID, CDI_KEY_GRIB2LOCALSECTIONNUMBER, (int) grib2LocalSectionNumber);
varDefKeyInt(varID, CDI_KEY_SECTION2PADDINGLENGTH, (int) size); varDefKeyInt(varID, CDI_KEY_SECTION2PADDINGLENGTH, (int) size);
unsigned char *section2Padding = (unsigned char*) Malloc(size); unsigned char *section2Padding = (unsigned char*) Malloc(size);
grib_get_bytes(gh, "section2Padding", section2Padding, &size); grib_get_bytes(gh, "section2Padding", section2Padding, &size);
varDefKeyBytes(varID, CDI_KEY_SECTION2PADDING, section2Padding, (int)size); varDefKeyBytes(varID, CDI_KEY_SECTION2PADDING, section2Padding, (int)size);
Free(section2Padding); Free(section2Padding);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment