WideStringToUCS4String returns no terminating null character
Original Reporter info from Mantis: mse
-
Reporter name: Martin Schreiber
Original Reporter info from Mantis: mse
- Reporter name: Martin Schreiber
Description:
rtl/inc/wustrings.inc WideStringToUCS4String and
rtl/unix/cwstring.pp WideStringToUCS4StringNoNulls return no terminating null character.
"
function WideStringToUCS4String(const s : WideString) : UCS4String;
[...]
result[destindex]:=UCS4Char(0);
{ destindex <= slen }
setlength(result,destindex);
"
should be
"
setlength(result,destindex+1);
"
wscoll crashes if the application is compiled with -gh.
PS: Please take into account that this functions are called very often for sorting strings, optimal performance is essential. I am not sure if the correct handling of surrogate pairs, which probably not many FPC users really need, is worth the loss on performance.
Mantis conversion info:
- Mantis ID: 10462
- Version: 2.2.1
- Fixed in version: 2.2.2
- Fixed in revision: 9529 (#f4e6e9ca)