Re: [PATCH] t4062: stop using repetition in regex
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 8, 2017, 22:26 UTC
- Message-ID
- <xmqq7eydae7r.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <xmqqinhxaf0i.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> So I find Dscho's concern quite valid, even though I do believe you > when you say the code somehow segfaults. I just can not tell > how/why it would segfault, though---it is possible that regexec() > implementation is stupid and does not realize that it can return early > reporting success without looking at the rest of the buffer, but > somehow I find it unlikely. > > Puzzled. > >> You get different results? How is that possible? The search string is >> NUL-terminated in each case, while the point of the test is that the >> file contents isn't, right?
Intellectual curiosity tells me we may want to find out why it fails, but in the meantime, I think replacing the test with "0$" to force the scanner to find either the end of line or the end of the buffer may be a good workaround. We do not have to care how many of random bytes are in front of the last "0" in order to ensure that the regexec_buf() does not overstep to 4097th byte, while seeing that regexec() that does not know how long the haystack is has to do so, no?