mirror of
				https://github.com/vim/vim.git
				synced 2025-10-30 09:47:20 -04:00 
			
		
		
		
	patch 9.1.0436: Crash when using '?' as separator for :s
Problem:  Crash when using '?' as separator for :s and pattern contains
          escaped '?'s (after 9.1.0409).
Solution: Always compute startplen. (zeertzjq).
related: neovim/neovim#28935
closes: 14832
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
			
			
This commit is contained in:
		
				
					committed by
					
						 Christian Brabandt
						Christian Brabandt
					
				
			
			
				
	
			
			
			
						parent
						
							cd79f8fbd3
						
					
				
				
					commit
					789679cfc4
				
			| @@ -620,6 +620,7 @@ skip_regexp_ex( | |||||||
| { | { | ||||||
|     magic_T	mymagic; |     magic_T	mymagic; | ||||||
|     char_u	*p = startp; |     char_u	*p = startp; | ||||||
|  |     size_t	startplen = STRLEN(startp); | ||||||
|  |  | ||||||
|     if (magic) |     if (magic) | ||||||
| 	mymagic = MAGIC_ON; | 	mymagic = MAGIC_ON; | ||||||
| @@ -642,12 +643,9 @@ skip_regexp_ex( | |||||||
| 	{ | 	{ | ||||||
| 	    if (dirc == '?' && newp != NULL && p[1] == '?') | 	    if (dirc == '?' && newp != NULL && p[1] == '?') | ||||||
| 	    { | 	    { | ||||||
| 		size_t	startplen = 0; |  | ||||||
|  |  | ||||||
| 		// change "\?" to "?", make a copy first. | 		// change "\?" to "?", make a copy first. | ||||||
| 		if (*newp == NULL) | 		if (*newp == NULL) | ||||||
| 		{ | 		{ | ||||||
| 		    startplen = STRLEN(startp); |  | ||||||
| 		    *newp = vim_strnsave(startp, startplen); | 		    *newp = vim_strnsave(startp, startplen); | ||||||
| 		    if (*newp != NULL) | 		    if (*newp != NULL) | ||||||
| 			p = *newp + (p - startp); | 			p = *newp + (p - startp); | ||||||
|   | |||||||
| @@ -173,6 +173,16 @@ func Test_substitute_repeat() | |||||||
|   call feedkeys("Qsc\<CR>y", 'tx') |   call feedkeys("Qsc\<CR>y", 'tx') | ||||||
|   bwipe! |   bwipe! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " Test :s with ? as separator. | ||||||
|  | func Test_substitute_question_separator() | ||||||
|  |   new | ||||||
|  |   call setline(1, '??:??') | ||||||
|  |   %s?\?\??!!?g | ||||||
|  |   call assert_equal('!!:!!', getline(1)) | ||||||
|  |   bwipe! | ||||||
|  | endfunc | ||||||
|  |  | ||||||
| " Test %s/\n// which is implemented as a special case to use a | " Test %s/\n// which is implemented as a special case to use a | ||||||
| " more efficient join rather than doing a regular substitution. | " more efficient join rather than doing a regular substitution. | ||||||
| func Test_substitute_join() | func Test_substitute_join() | ||||||
|   | |||||||
| @@ -704,6 +704,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     436, | ||||||
| /**/ | /**/ | ||||||
|     435, |     435, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user