Fix heap buffer overflow; fix
@@ -324,8 +324,7 @@ str_index_str_by_char_search(mrb_state *mrb, const char *p, const char *pend, co
}
/* Searching */
- if (p < pend && pend - p >= slen) {
- for (;;) {
+ while (p < pend && pend - p >= slen) {
const char *pivot;
if (memcmp(p, s, slen) == 0) {
@@ -340,7 +339,6 @@ str_index_str_by_char_search(mrb_state *mrb, const char *p, const char *pend, co
off ++;
} while (p < pivot);
}
- }
return -1;
}
