430 |
|
procedure TOutputBlockItem.SetString(out S: AnsiString; Buf: PByte; |
431 |
|
Len: integer; CodePage: TSystemCodePage); |
432 |
|
var rs: RawByteString; |
433 |
+ |
i: integer; |
434 |
|
begin |
435 |
< |
system.SetString(rs,PAnsiChar(Buf),len); |
435 |
> |
{There seems to be a memory manager problem with SetString that can cause |
436 |
> |
an unhandled exception at the end of a program if it is used to set the |
437 |
> |
string. Safer to copy characters one by one. Note that Setlength does |
438 |
> |
not work around the bug either.} |
439 |
> |
rs := ''; |
440 |
> |
for i := 0 to len-1 do |
441 |
> |
rs := rs + PAnsiChar(buf+i)^; |
442 |
> |
// system.SetString(rs,PAnsiChar(Buf),len); |
443 |
|
SetCodePage(rs,CodePage,false); |
444 |
|
S := rs; |
445 |
|
end; |