ECC-1502: Fortran encoding test

This commit is contained in:
Shahram Najm 2023-01-05 17:42:13 +00:00
parent 7e3889eeed
commit e744bec7a2
1 changed files with 14 additions and 8 deletions

View File

@ -103,20 +103,26 @@ int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberO
char* s = str;
Assert(numberOfCharacters < 512);
Assert(string);
slen = strlen(string);
memcpy(s, string, slen);
/* There is a case where string == NULL:
* bufr_dump -Efortran data/bufr/btem_109.bufr
* This writes:
* call codes_set(ibufr,'shipOrMobileLandStationIdentifier','')
* For some odd reason this gets passed in as a NULL string here!
* To be further investigated
*/
if (string) {
slen = strlen(string);
if (slen > numberOfCharacters) {
return GRIB_ENCODING_ERROR;
}
memcpy(s, string, slen);
}
/* if (remainder) byteOffset++; */
if (numberOfCharacters == 0)
return err;
if (slen > numberOfCharacters) {
return GRIB_ENCODING_ERROR;
}
p = (unsigned char*)bitStream + byteOffset;
if (remainder == 0) {