Fix bug in iconv_string.
diff --git a/extras/ChangeLog b/extras/ChangeLog
index e74835b..c92be18 100644
--- a/extras/ChangeLog
+++ b/extras/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-04  Bruno Haible  <bruno@clisp.org>
+
+	* iconv_string.c (iconv_string): Treat incomplete byte sequence like
+	invalid byte sequence.
+	Reported by shosas at <https://savannah.gnu.org/bugs/?32399>.
+
 2003-05-10  Bruno Haible  <bruno@clisp.org>
 
 	* iconv_string.c (iconv_string): Don't return -1 just because the
diff --git a/extras/iconv_string.c b/extras/iconv_string.c
index f2c4b52..ebfab2e 100644
--- a/extras/iconv_string.c
+++ b/extras/iconv_string.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2001, 2003 Bruno Haible.
+/* Copyright (C) 1999-2001, 2003, 2011 Bruno Haible.
    This file is not part of the GNU LIBICONV Library.
    This file is put into the public domain.  */
 
@@ -76,14 +76,10 @@
       size_t outsize = tmpbufsize;
       size_t res = iconv(cd,&inptr,&insize,&outptr,&outsize);
       if (res == (size_t)(-1) && errno != E2BIG) {
-        if (errno == EINVAL)
-          break;
-        else {
-          int saved_errno = errno;
-          iconv_close(cd);
-          errno = saved_errno;
-          return -1;
-        }
+        int saved_errno = (errno == EINVAL ? EILSEQ : errno);
+        iconv_close(cd);
+        errno = saved_errno;
+        return -1;
       }
       count += outptr-tmpbuf;
     }