mirror of
https://github.com/git/git.git
synced 2026-01-28 03:22:25 +00:00
The new regexec_buf() function operates on buffers with an explicitly specified length, rather than NUL-terminated strings. We need to use this function whenever the buffer we want to pass to regexec() may have been mmap()ed (and is hence not NUL-terminated). Note: the original motivation for this patch was to fix a bug where `git diff -G <regex>` would crash. This patch converts more callers, though, some of which explicitly allocated and constructed NUL-terminated strings (or worse: modified read-only buffers to insert NULs). Some of the buffers actually may be NUL-terminated. As regexec_buf() uses REG_STARTEND where available, but has to fall back to allocating and constructing NUL-terminated strings where REG_STARTEND is not available, this makes the code less efficient in the latter case. However, given the widespread support for REG_STARTEND, combined with the improved ease of code maintenance, we strike the balance in favor of REG_STARTEND. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6.1 KiB
6.1 KiB