r938: on an error save the original errno before calling iconv to reset
authorHerb Lewis <herb@samba.org>
Fri, 28 May 2004 17:57:18 +0000 (17:57 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:51:50 +0000 (10:51 -0500)
the conversion state
(This used to be commit 4a5a122b3a85c653bbf458342400f3b8a69dc615)

source3/lib/iconv.c

index 7df73192f24a6df5b25626dc041c60e5761efce3..4c9ecf992e6790190e0ee1e4e0598de9ff237863 100644 (file)
@@ -129,7 +129,11 @@ static size_t sys_iconv(void *cd,
        size_t ret = iconv((iconv_t)cd, 
                           inbuf, inbytesleft, 
                           outbuf, outbytesleft);
-       if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL);
+       if (ret == (size_t)-1) {
+               int saved_errno = errno;
+               iconv(cd, NULL, NULL, NULL, NULL);
+               errno = saved_errno;
+       }
        return ret;
 #else
        errno = EINVAL;