Mercurial > vim
comparison src/search.c @ 22478:5193420617f1 v8.2.1787
patch 8.2.1787: crash with 'incsearch' and very long line
Commit: https://github.com/vim/vim/commit/795aaa1e84d76a6fe066694de9876b8a21cbe40c
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Oct 2 20:36:01 2020 +0200
patch 8.2.1787: crash with 'incsearch' and very long line
Problem: Crash with 'incsearch' and very long line.
Solution: Check whether regprog becomes NULL. (closes https://github.com/vim/vim/issues/7063)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 02 Oct 2020 20:45:03 +0200 |
parents | f4d1fe8e04cf |
children | 5055805908f5 |
comparison
equal
deleted
inserted
replaced
22477:eb2150150b99 | 22478:5193420617f1 |
---|---|
757 tm, timed_out | 757 tm, timed_out |
758 #else | 758 #else |
759 NULL, NULL | 759 NULL, NULL |
760 #endif | 760 #endif |
761 ); | 761 ); |
762 // vim_regexec_multi() may clear "regprog" | |
763 if (regmatch.regprog == NULL) | |
764 break; | |
762 // Abort searching on an error (e.g., out of stack). | 765 // Abort searching on an error (e.g., out of stack). |
763 if (called_emsg > called_emsg_before | 766 if (called_emsg > called_emsg_before |
764 #ifdef FEAT_RELTIME | 767 #ifdef FEAT_RELTIME |
765 || (timed_out != NULL && *timed_out) | 768 || (timed_out != NULL && *timed_out) |
766 #endif | 769 #endif |
856 )) == 0) | 859 )) == 0) |
857 { | 860 { |
858 match_ok = FALSE; | 861 match_ok = FALSE; |
859 break; | 862 break; |
860 } | 863 } |
864 // vim_regexec_multi() may clear "regprog" | |
865 if (regmatch.regprog == NULL) | |
866 break; | |
861 matchpos = regmatch.startpos[0]; | 867 matchpos = regmatch.startpos[0]; |
862 endpos = regmatch.endpos[0]; | 868 endpos = regmatch.endpos[0]; |
863 # ifdef FEAT_EVAL | 869 # ifdef FEAT_EVAL |
864 submatch = first_submatch(®match); | 870 submatch = first_submatch(®match); |
865 # endif | 871 # endif |
970 if (timed_out != NULL && *timed_out) | 976 if (timed_out != NULL && *timed_out) |
971 match_ok = FALSE; | 977 match_ok = FALSE; |
972 #endif | 978 #endif |
973 break; | 979 break; |
974 } | 980 } |
981 // vim_regexec_multi() may clear "regprog" | |
982 if (regmatch.regprog == NULL) | |
983 break; | |
975 | 984 |
976 // Need to get the line pointer again, a | 985 // Need to get the line pointer again, a |
977 // multi-line search may have made it invalid. | 986 // multi-line search may have made it invalid. |
978 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); | 987 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); |
979 } | 988 } |
1063 if (loop && lnum == start_pos.lnum) | 1072 if (loop && lnum == start_pos.lnum) |
1064 break; // if second loop, stop where started | 1073 break; // if second loop, stop where started |
1065 } | 1074 } |
1066 at_first_line = FALSE; | 1075 at_first_line = FALSE; |
1067 | 1076 |
1077 // vim_regexec_multi() may clear "regprog" | |
1078 if (regmatch.regprog == NULL) | |
1079 break; | |
1080 | |
1068 /* | 1081 /* |
1069 * Stop the search if wrapscan isn't set, "stop_lnum" is | 1082 * Stop the search if wrapscan isn't set, "stop_lnum" is |
1070 * specified, after an interrupt, after a match and after looping | 1083 * specified, after an interrupt, after a match and after looping |
1071 * twice. | 1084 * twice. |
1072 */ | 1085 */ |
2909 regmatch.startpos[0].col++; | 2922 regmatch.startpos[0].col++; |
2910 nmatched = vim_regexec_multi(®match, curwin, curbuf, | 2923 nmatched = vim_regexec_multi(®match, curwin, curbuf, |
2911 pos.lnum, regmatch.startpos[0].col, NULL, NULL); | 2924 pos.lnum, regmatch.startpos[0].col, NULL, NULL); |
2912 if (nmatched != 0) | 2925 if (nmatched != 0) |
2913 break; | 2926 break; |
2914 } while (direction == FORWARD ? regmatch.startpos[0].col < pos.col | 2927 } while (regmatch.regprog != NULL |
2928 && direction == FORWARD ? regmatch.startpos[0].col < pos.col | |
2915 : regmatch.startpos[0].col > pos.col); | 2929 : regmatch.startpos[0].col > pos.col); |
2916 | 2930 |
2917 if (called_emsg == called_emsg_before) | 2931 if (called_emsg == called_emsg_before) |
2918 { | 2932 { |
2919 result = (nmatched != 0 | 2933 result = (nmatched != 0 |