]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
wc: avoid undefined conversion state
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Sep 2023 02:23:56 +0000 (19:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 23 Sep 2023 07:28:26 +0000 (00:28 -0700)
* src/wc.c (wc): When mbrtowc returns (size_t) -1, zero the
conversion state, since POSIX says it’s undefined.

src/wc.c

index 1753acfc1649aa3ed7d857c2b694d410b9ef14f9..fdbeed73932d3a7e4c635c6085e95a8b05fedba8 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -519,6 +519,8 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
                          character (that is, chars is not incremented).  */
                       p++;
                       bytes_read--;
+                      mbszero (&state);
+                      in_shift = false;
                       continue;
                     }
                   if (mbsinit (&state))