summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/iconv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c
index 7df73192f2..4c9ecf992e 100644
--- a/source3/lib/iconv.c
+++ b/source3/lib/iconv.c
@@ -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;