win32 widestring copy error
Original Reporter info from Mantis: mse
-
Reporter name: Martin Schreiber
Original Reporter info from Mantis: mse
- Reporter name: Martin Schreiber
Description:
Call stack of the copy operation in the testcase:
#0 0040573C wstrings.inc:385 fpc_widestr_assign(S1=(POINTER) $9d984, S2=(POINTER) $9d984)
#1 00401436 widestringcopy2.pas:12 TESTPROC(AVALUE=(WIDESTRING) $9d984)
#2 00401462 widestringcopy2.pas:18 main()
Note that S1 = S2.
fpc_widestring_assign:
Procedure fpc_WideStr_Assign (Var S1 : Pointer;S2 : Pointer);[Public,Alias:'FPC_WIDESTR_ASSIGN']; compilerproc;
{
Assigns S2 to S1 (S1:=S2), taking in account reference counts.
}
begin
{$ifdef FPC_WINLIKEWIDESTRING}
{ Decrease the reference count on the old S1 }
fpc_widestr_decr_ref (S1); <<<<<<<<<<<-----releases the *source* string!
if S2<>nil then
begin
S1:=NewWidestring(length(WideString(S2))); <<<<<<<<<----S2 is invalid
move(s2^,s1^,(length(WideString(s1))+1)*sizeof(widechar));
end
There will be an AV if "winwidestringalloc:= false;" is uncommented.
Suggestion: Do nothing if S1 = S2 for FPC_WINLIKEWIDESTRING.
Mantis conversion info:
- Mantis ID: 9187
- Platform: win32
- Version: 2.2.0
- Fixed in version: 2.2.0
- Fixed in revision: 7877 (#eeb0b484)