summaryrefslogtreecommitdiff
path: root/packages/iconvenc
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-06-27 11:58:02 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-06-27 11:58:02 +0000
commit2335173b1bc38781742c4531d3e1bd82ac518db8 (patch)
treebedbc77a0e60e0b81b5c3663ea25135bd33a6366 /packages/iconvenc
parentd80b69c1f27f0dfb352c057ad2f42c89b31a437b (diff)
downloadfpc-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.inc10
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