NewStr('') should return NullStr
Original Reporter info from Mantis: nanobit @nanobit
-
Reporter name:
Original Reporter info from Mantis: nanobit @nanobit
- Reporter name:
Description:
function NewStr(const S: string): PString; overload;
If input is emptyString,
then result should be emptyString (sysutils.NullStr) too.
Currently, the result is nil, which leads to a crash in code like this:
ptrStr := newStr('');
ptrStr^ := inttostr(123); // crash
procedure DisposeStr(S: PString); overload;
Setting the nil in this routine is useless, it's no result-variable.
S is invalid pointer after returnal.
Both routines are quite dangerous.
Hopefully, not many use them...
Mantis conversion info:
- Mantis ID: 35366
- OS: Windows
- OS Build: 10
- Platform: win32
- Version: 3.0.4
- Monitored by: » @xhajt03 (Tomas Hajny)