Mercurial > vim
comparison src/regexp_bt.c @ 29191:0af5fe160e4e v8.2.5115
patch 8.2.5115: search timeout is overrun with some patterns
Commit: https://github.com/vim/vim/commit/616592e0816d2d9f893fcd95e3e1e0fbc5893168
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 17 15:17:10 2022 +0100
patch 8.2.5115: search timeout is overrun with some patterns
Problem: Search timeout is overrun with some patterns.
Solution: Check for timeout in more places. Make the flag volatile and
atomic. Use assert_inrange() to see what happened.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 17 Jun 2022 16:30:06 +0200 |
parents | b90bca860b5a |
children | c7aa0c46acd5 |
comparison
equal
deleted
inserted
replaced
29190:a4f0e5e61728 | 29191:0af5fe160e4e |
---|---|
3150 *scan = rp->rs_scan; | 3150 *scan = rp->rs_scan; |
3151 | 3151 |
3152 regstack.ga_len -= sizeof(regitem_T); | 3152 regstack.ga_len -= sizeof(regitem_T); |
3153 } | 3153 } |
3154 | 3154 |
3155 #ifdef FEAT_RELTIME | |
3156 /* | |
3157 * Check if the timer expired, return TRUE if so. | |
3158 */ | |
3159 static int | |
3160 bt_did_time_out(int *timed_out) | |
3161 { | |
3162 if (*timeout_flag) | |
3163 { | |
3164 if (timed_out != NULL) | |
3165 { | |
3166 if (!*timed_out) | |
3167 ch_log(NULL, "BT regexp timed out"); | |
3168 *timed_out = TRUE; | |
3169 } | |
3170 return TRUE; | |
3171 } | |
3172 return FALSE; | |
3173 } | |
3174 #endif | |
3175 | |
3155 /* | 3176 /* |
3156 * Save the current subexpr to "bp", so that they can be restored | 3177 * Save the current subexpr to "bp", so that they can be restored |
3157 * later by restore_subexpr(). | 3178 * later by restore_subexpr(). |
3158 */ | 3179 */ |
3159 static void | 3180 static void |
3265 { | 3286 { |
3266 status = RA_FAIL; | 3287 status = RA_FAIL; |
3267 break; | 3288 break; |
3268 } | 3289 } |
3269 #ifdef FEAT_RELTIME | 3290 #ifdef FEAT_RELTIME |
3270 if (*timeout_flag) | 3291 if (bt_did_time_out(timed_out)) |
3271 { | 3292 { |
3272 if (timed_out != NULL) | |
3273 *timed_out = TRUE; | |
3274 status = RA_FAIL; | 3293 status = RA_FAIL; |
3275 break; | 3294 break; |
3276 } | 3295 } |
3277 #endif | 3296 #endif |
3278 status = RA_CONT; | 3297 status = RA_CONT; |
4685 // If we want to continue the inner loop or didn't pop a state | 4704 // If we want to continue the inner loop or didn't pop a state |
4686 // continue matching loop | 4705 // continue matching loop |
4687 if (status == RA_CONT || rp == (regitem_T *) | 4706 if (status == RA_CONT || rp == (regitem_T *) |
4688 ((char *)regstack.ga_data + regstack.ga_len) - 1) | 4707 ((char *)regstack.ga_data + regstack.ga_len) - 1) |
4689 break; | 4708 break; |
4709 | |
4710 #ifdef FEAT_RELTIME | |
4711 if (bt_did_time_out(timed_out)) | |
4712 { | |
4713 status = RA_FAIL; | |
4714 break; | |
4715 } | |
4716 #endif | |
4690 } | 4717 } |
4691 | 4718 |
4692 // May need to continue with the inner loop, starting at "scan". | 4719 // May need to continue with the inner loop, starting at "scan". |
4693 if (status == RA_CONT) | 4720 if (status == RA_CONT) |
4694 continue; | 4721 continue; |
4974 if (has_mbyte) | 5001 if (has_mbyte) |
4975 col += (*mb_ptr2len)(rex.line + col); | 5002 col += (*mb_ptr2len)(rex.line + col); |
4976 else | 5003 else |
4977 ++col; | 5004 ++col; |
4978 #ifdef FEAT_RELTIME | 5005 #ifdef FEAT_RELTIME |
4979 if (*timeout_flag) | 5006 if (bt_did_time_out(timed_out)) |
4980 { | |
4981 if (timed_out != NULL) | |
4982 *timed_out = TRUE; | |
4983 break; | 5007 break; |
4984 } | |
4985 #endif | 5008 #endif |
4986 } | 5009 } |
4987 } | 5010 } |
4988 | 5011 |
4989 theend: | 5012 theend: |