diff --git a/ChangeLog b/ChangeLog
index a6fd4b6a3cc27c953cb87f10a13bd24ddf7a032e..db19121bf44aad3e40b25e26a900832a801025ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,10 @@ CVS code -
 	- Make sure that the current position in the history list is
 	  properly set to the bottom if we cancel out of the prompt.
 	  New function history_reset(); changes to nanogetstr(). (DLR)
+- chars.c:
+  mbstrchr()
+	- Don't count matches between valid and invalid multibyte
+	  sequences anymore, for consistency. (DLR)
 - files.c:
   open_file()
 	- Assert that filename isn't NULL, and don't do anything special
diff --git a/src/chars.c b/src/chars.c
index 0d3a9ddf3077fd0eee2480cec2773b2a8ec24455..506ad1d4bd0917337d8267864269591fe8d01a2d 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -808,6 +808,7 @@ char *mbstrchr(const char *s, char *c)
 
 #ifdef ENABLE_UTF8
     if (ISSET(USE_UTF8)) {
+	bool bad_c_mb = FALSE, bad_s_mb = FALSE;
 	char *s_mb = charalloc(MB_CUR_MAX);
 	const char *q = s;
 	wchar_t ws, wc;
@@ -816,6 +817,7 @@ char *mbstrchr(const char *s, char *c)
 	if (c_mb_len <= 0) {
 	    mbtowc(NULL, NULL, 0);
 	    wc = (unsigned char)*c;
+	    bad_c_mb = TRUE;
 	}
 
 	while (*s != '\0') {
@@ -824,9 +826,10 @@ char *mbstrchr(const char *s, char *c)
 	    if (mbtowc(&ws, s_mb, s_mb_len) <= 0) {
 		mbtowc(NULL, NULL, 0);
 		ws = (unsigned char)*s;
+		bad_s_mb = TRUE;
 	    }
 
-	    if (ws == wc)
+	    if (bad_s_mb == bad_c_mb && ws == wc)
 		break;
 
 	    s += s_mb_len;