From: Johannes Schindelin Date: Thu, 08 Sep 2016 07:54:51 GMT Subject: Re: [PATCH v2 3/3] Use the newly-introduced regexec_buf() function Message-ID: In-Reply-To: <324ecba64eb0436988aca846fb444eafda290d13.1473319844.git.johannes.schindelin@gmx.de> Hi, On Thu, 8 Sep 2016, Johannes Schindelin wrote: > 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 ` 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 > --- > diff.c | 3 ++- > diffcore-pickaxe.c | 18 ++++++++---------- > xdiff-interface.c | 13 ++++--------- > 3 files changed, 14 insertions(+), 20 deletions(-) I just realized that this should switch the test_expect_failure from 1/3 to a test_expect_success. Will send out v3 in a moment. Ciao, Dscho