The EXI parser is decoding the elemnents QName in string without adding the terminal character '\0'
I advise you to change:
decodeString(EXIStream strm, String string_val) and
decodeStringOnly(EXIStream strm, Index str_length, String string_val)
to this:
errorCode decodeString(EXIStream strm, String string_val)
{
errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR;
UnsignedInteger string_length = 0;
DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (string)"));
TRY(decodeUnsignedInteger(strm, &string_length));
TRY(allocateStringMemoryManaged(&(string_val->str),(Index) string_length + 1, &strm->memList));
return decodeStringOnly(strm,(Index) string_length + 1, string_val);
}
errorCode decodeStringOnly(EXIStream strm, Index str_length, String string_val)
{
// Assume no Restricted Character Set is defined
//TODO: Handle the case when Restricted Character Set is defined
// The exact size of the string is known at this point. This means that // this is the place to allocate the memory for the { CharType* str; }!!! errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; Index i = 0; Index writerPosition = 0; UnsignedInteger tmp_code_point = 0; string_val->length = str_length - 1; for(i = 0; i < str_length -1; i++) { TRY(decodeUnsignedInteger(strm, &tmp_code_point)); TRY(writeCharToString(string_val, (uint32_t) tmp_code_point, &writerPosition)); } TRY(writeEndToString(string_val, &writerPosition)); return EXIP_OK;
}
Anonymous
This is not really a bug since the strings are intentionally length prefixed and hence there is no need for NULL terminating symbol. I agree thought that in many simple use cases the NULL terminated strings can be easier to use.
I will consider your proposed improvement, thanks for the feedback!
Best,
Rumen