Skip to content

Commit 891a793

Browse files
committed
Fix bug in iconv_string.
1 parent a24cfd8 commit 891a793

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

extras/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2011-06-04 Bruno Haible <bruno@clisp.org>
2+
3+
* iconv_string.c (iconv_string): Treat incomplete byte sequence like
4+
invalid byte sequence.
5+
Reported by shosas at <https://savannah.gnu.org/bugs/?32399>.
6+
17
2003-05-10 Bruno Haible <bruno@clisp.org>
28

39
* iconv_string.c (iconv_string): Don't return -1 just because the

extras/iconv_string.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 1999-2001, 2003 Bruno Haible.
1+
/* Copyright (C) 1999-2001, 2003, 2011 Bruno Haible.
22
This file is not part of the GNU LIBICONV Library.
33
This file is put into the public domain. */
44

@@ -76,14 +76,10 @@ int iconv_string (const char* tocode, const char* fromcode,
7676
size_t outsize = tmpbufsize;
7777
size_t res = iconv(cd,&inptr,&insize,&outptr,&outsize);
7878
if (res == (size_t)(-1) && errno != E2BIG) {
79-
if (errno == EINVAL)
80-
break;
81-
else {
82-
int saved_errno = errno;
83-
iconv_close(cd);
84-
errno = saved_errno;
85-
return -1;
86-
}
79+
int saved_errno = (errno == EINVAL ? EILSEQ : errno);
80+
iconv_close(cd);
81+
errno = saved_errno;
82+
return -1;
8783
}
8884
count += outptr-tmpbuf;
8985
}

0 commit comments

Comments
 (0)