summaryrefslogtreecommitdiff
path: root/iconv/gconv.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-08-21 14:43:18 +0000
committerUlrich Drepper <drepper@redhat.com>2007-08-21 14:43:18 +0000
commit55ea8790a9fdb6e1320be8e5ad84bca04dbf9a7d (patch)
tree8228ddea4603f6c82e9005f62c56c73bff62be9d /iconv/gconv.c
parent0b82ff747eede0f77c524bfce4cf93cb929a953f (diff)
downloadglibc-55ea8790a9fdb6e1320be8e5ad84bca04dbf9a7d.tar.gz
[BZ #4896, BZ #4936]
2007-08-21 Ulrich Drepper <drepper@redhat.com> [BZ #4936] * iconv/gconv.c (__gconv): If flush was successful, clear rest of the state. * iconvdata/Makefile: Add rules to build and run bug-iconv5. * iconvdata/bug-iconv5.c: New file. [BZ #4896]
Diffstat (limited to 'iconv/gconv.c')
-rw-r--r--iconv/gconv.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/iconv/gconv.c b/iconv/gconv.c
index cd43d3d6fb..1b64455537 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -1,6 +1,6 @@
/* Convert characters in input buffer using conversion descriptor to
output buffer.
- Copyright (C) 1997-2001, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997-2001, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -55,11 +55,19 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
#endif
if (inbuf == NULL || *inbuf == NULL)
- /* We just flush. */
- result = DL_CALL_FCT (fct,
- (cd->__steps, cd->__data, NULL, NULL, NULL,
- irreversible,
- cd->__data[last_step].__outbuf == NULL ? 2 : 1, 0));
+ {
+ /* We just flush. */
+ result = DL_CALL_FCT (fct,
+ (cd->__steps, cd->__data, NULL, NULL, NULL,
+ irreversible,
+ cd->__data[last_step].__outbuf == NULL ? 2 : 1,
+ 0));
+
+ /* If the flush was successful clear the rest of the state. */
+ if (result == __GCONV_OK)
+ for (size_t cnt = 0; cnt <= last_step; ++cnt)
+ cd->__data[cnt].__invocation_counter = 0;
+ }
else
{
const unsigned char *last_start;