mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-21 11:49:18 +02:00
* patch from Ido to add error detection to iconvert's flush statement, since
that can also overflow. (mantis 13896) git-svn-id: trunk@13331 -
This commit is contained in:
parent
1f6ec379de
commit
b17cfcabc6
@ -49,7 +49,15 @@ begin
|
||||
|
||||
// iconv has a buffer that needs flushing, specially if the last char is not #0
|
||||
iconv(H, nil, nil, @Dst, @Outlen);
|
||||
|
||||
lerr:=cerrno;
|
||||
if (iconvres=Cint(-1)) and (lerr=ESysE2BIG) then
|
||||
begin
|
||||
Offset:=Dst-PChar(Res);
|
||||
SetLength(Res, Length(Res)+InLen*2+5); // 5 is minimally one utf-8 char
|
||||
Dst:=PChar(Res)+Offset;
|
||||
OutLen:=Length(Res)-Offset;
|
||||
iconv(H, nil, nil, @Dst, @Outlen);
|
||||
end;
|
||||
// trim output buffer
|
||||
SetLength(Res, Length(Res) - Outlen);
|
||||
finally
|
||||
|
Loading…
Reference in New Issue
Block a user