diff --git a/src/interfaces/odbc/multibyte.c b/src/interfaces/odbc/multibyte.c
index 3cc3efe350ace498a4344a06d6f1b6dc937bd2d3..476f3c42cd710b6807dfacff6a3f5fd32593d5fd 100644
--- a/src/interfaces/odbc/multibyte.c
+++ b/src/interfaces/odbc/multibyte.c
@@ -253,18 +253,18 @@ unsigned char *
 pg_mbschr(int csc, const unsigned char *string, unsigned int character)
 {
 	int			mb_st = 0;
-	unsigned char *s;
-	s = (unsigned char *) string;
+	const unsigned char *s, *rs = NULL;
 
-	for(;;) 
+	for(s = string; *s ; s++) 
 	{
 		mb_st = pg_CS_stat(mb_st, (unsigned char) *s, csc);
-		if (mb_st == 0 && (*s == character || *s == 0))
+		if (mb_st == 0 && (*s == character))
+		{
+			rs = s;
 			break;
-		else
-			s++;
+		}
 	}
-	return (s);
+	return (rs);
 }
 
 int