diff --git a/ChangeLog b/ChangeLog
index 092d2f68e726006fbe63058d22f00588b582f35b..bf6d70a0de69eb03955344f5a90bb074034a5b98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 	* doc/man/{nano.1,nanorc.5}, doc/texinfo/nano.texi: Add deprecation
 	notices for the options 'set const', 'set poslog' and '--poslog'.
 	Suggested by Eitan Adler.
+	* src/chars.c (mbstrcasestr, mbrevstrcasestr): When searching, find
+	only valid UTF-8 byte sequences.  This fixes Savannah bug #45579.
 
 2015-07-22  Mike Frysinger  <vapier@gentoo.org>
 	* src/files.c (check_dotnano), src/global.c (thanks_for_all_the_fish),
diff --git a/src/chars.c b/src/chars.c
index ccd9f33a3b1b0f788780a9f9826941da1a93876a..2f8de139e295efe9a44904e851c18f99bdf27def 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -636,7 +636,8 @@ char *mbstrcasestr(const char *haystack, const char *needle)
 
 	for (; *haystack != '\0' && haystack_len >= needle_len;
 		haystack += move_mbright(haystack, 0), haystack_len--) {
-	    if (mbstrncasecmp(haystack, needle, needle_len) == 0)
+	    if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
+			mblen(haystack, MB_CUR_MAX) > 0)
 		return (char *)haystack;
 	}
 
@@ -729,8 +730,9 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
 	rev_start_len = mbstrlen(rev_start);
 
 	while (!begin_line) {
-	    if (rev_start_len >= needle_len && mbstrncasecmp(rev_start,
-		needle, needle_len) == 0)
+	    if (rev_start_len >= needle_len &&
+			mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
+			mblen(rev_start, MB_CUR_MAX) > 0)
 		return (char *)rev_start;
 
 	    if (rev_start == haystack)