Merge branch 'js/regexec-buf'
Fix for potential segv introduced in v2.11.0 and later (also v2.10.2). * js/regexec-buf: pickaxe: fix segfault with '-S<...> --pickaxe-regex'
This commit is contained in:
		| @ -81,12 +81,15 @@ static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws) | |||||||
| 		regmatch_t regmatch; | 		regmatch_t regmatch; | ||||||
| 		int flags = 0; | 		int flags = 0; | ||||||
|  |  | ||||||
| 		while (*data && | 		while (sz && *data && | ||||||
| 		       !regexec_buf(regexp, data, sz, 1, ®match, flags)) { | 		       !regexec_buf(regexp, data, sz, 1, ®match, flags)) { | ||||||
| 			flags |= REG_NOTBOL; | 			flags |= REG_NOTBOL; | ||||||
| 			data += regmatch.rm_eo; | 			data += regmatch.rm_eo; | ||||||
| 			if (*data && regmatch.rm_so == regmatch.rm_eo) | 			sz -= regmatch.rm_eo; | ||||||
|  | 			if (sz && *data && regmatch.rm_so == regmatch.rm_eo) { | ||||||
| 				data++; | 				data++; | ||||||
|  | 				sz--; | ||||||
|  | 			} | ||||||
| 			cnt++; | 			cnt++; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | |||||||
| @ -19,4 +19,9 @@ test_expect_success '-G matches' ' | |||||||
| 	test 4096-zeroes.txt = "$(cat out)" | 	test 4096-zeroes.txt = "$(cat out)" | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  | test_expect_success '-S --pickaxe-regex' ' | ||||||
|  | 	git diff --name-only -S0 --pickaxe-regex HEAD^ >out && | ||||||
|  | 	verbose test 4096-zeroes.txt = "$(cat out)" | ||||||
|  | ' | ||||||
|  |  | ||||||
| test_done | test_done | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Junio C Hamano
					Junio C Hamano