diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib.c | 4 |
2 files changed, 8 insertions, 2 deletions
@@ -1,5 +1,11 @@ 2010-02-27 Kaz Kylheku <kkylheku@gmail.com> + * lib.c (search_str): Bugfix for empty haystack case: checks for end + of string must use postincrement on the index, otherwise the access + goes past the null terminator. + +2010-02-27 Kaz Kylheku <kkylheku@gmail.com> + * match.c (match_lines): Bugfix in freeform directive. If the virtual line is partially matched, the remainder of the line is folded back into list form. In this case, the @@ -882,7 +882,7 @@ val search_str(val haystack, val needle, val start_num, val from_end) pos = f - h; else pos = -1; - } while (pos != -1 && (good = pos) != -1 && from_end && h[++start]); + } while (pos != -1 && (good = pos) != -1 && from_end && h[start++]); } else { size_t ln = c_num(length_str(needle)); @@ -892,7 +892,7 @@ val search_str(val haystack, val needle, val start_num, val from_end) if (!wcsncmp(h + start, n, ln)) good = start; - } while (h[++start] && (from_end || good == -1)); + } while (h[start++] && (from_end || good == -1)); } return (good == -1) ? nil : num(good); } |