cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Fix overflow exception when serializing

Open scc-tw opened this issue 2 years ago • 1 comments

When the MSB of the initial wchar_t is set, the lowSurrogate would be inferred to be "unsigned". The if statement would be triggered, and the exception "UTF-16 string has invalid low surrogate" would be thrown.

This needs to be fixed by making the type "signed" and then comparing it to the integer values of the specified constants.

scc-tw avatar Mar 09 '23 10:03 scc-tw

You could also refer to: The wchar_t type is defined by MIDL as an unsigned short(16-bit) data object [1].

Type wchar_­t is a distinct type that has an implementation-defined signed or unsigned integer type as its underlying type [2].

[1] https://learn.microsoft.com/en-us/windows/win32/midl/wchar-t [2] https://eel.is/c++draft/basic.types#basic.fundamental-8

scc-tw avatar Mar 09 '23 10:03 scc-tw