diff options
| author | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-06-27 11:58:02 +0000 |
|---|---|---|
| committer | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-06-27 11:58:02 +0000 |
| commit | 2335173b1bc38781742c4531d3e1bd82ac518db8 (patch) | |
| tree | bedbc77a0e60e0b81b5c3663ea25135bd33a6366 /packages/iconvenc | |
| parent | d80b69c1f27f0dfb352c057ad2f42c89b31a437b (diff) | |
| download | fpc-2335173b1bc38781742c4531d3e1bd82ac518db8.tar.gz | |
* patch from Ido to add error detection to iconvert's flush statement, since
that can also overflow. (mantis 13896)
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@13331 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/iconvenc')
| -rw-r--r-- | packages/iconvenc/src/iconvert.inc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/iconvenc/src/iconvert.inc b/packages/iconvenc/src/iconvert.inc index bee2a9d2f6..c0d265e269 100644 --- a/packages/iconvenc/src/iconvert.inc +++ b/packages/iconvenc/src/iconvert.inc @@ -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 |
