diff --git a/lib/search/regex.c b/lib/search/regex.c
index 082fa2c..1711af4 100644
a
|
b
|
mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data, |
877 | 877 | virtual_pos = current_pos; |
878 | 878 | } |
879 | 879 | |
| 880 | #ifdef SEARCH_TYPE_GLIB |
| 881 | /* Glib doesn't like invalid UTF-8 so sanitize it first: ticket 3449. |
| 882 | Be careful: there might be embedded NULs in the strings. */ |
| 883 | if (lc_mc_search->is_utf8) |
| 884 | { |
| 885 | char *p = lc_mc_search->regex_buffer->str; |
| 886 | char *end = p + lc_mc_search->regex_buffer->len; |
| 887 | while (p < end) |
| 888 | { |
| 889 | gunichar c = g_utf8_get_char_validated (p, -1); |
| 890 | if (c != (gunichar) (-1) && c != (gunichar) (-2)) |
| 891 | { |
| 892 | p = g_utf8_next_char (p); |
| 893 | } |
| 894 | else |
| 895 | { |
| 896 | /* U+FFFD would be the proper choice, but then we'd have to |
| 897 | create a new string and maintain mapping between old and new offsets. |
| 898 | So rather do a byte by byte replacement. */ |
| 899 | *p++ = '\0'; |
| 900 | } |
| 901 | } |
| 902 | } |
| 903 | #endif /* SEARCH_TYPE_GLIB */ |
| 904 | |
880 | 905 | switch (mc_search__regex_found_cond (lc_mc_search, lc_mc_search->regex_buffer)) |
881 | 906 | { |
882 | 907 | case COND__FOUND_OK: |