mirror of
https://github.com/git/git.git
synced 2026-01-27 10:58:50 +00:00
diff_grep: add assertions verifying that the buffers are NUL-terminated
Before calling regexec() on the file contents, we better be certain that the strings fulfill the contract of C strings assumed by said function. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -49,6 +49,8 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
|
||||
assert(!one || one->ptr[one->size] == '\0');
|
||||
assert(!two || two->ptr[two->size] == '\0');
|
||||
if (!one)
|
||||
return !regexec(regexp, two->ptr, 1, ®match, 0);
|
||||
if (!two)
|
||||
|
||||
Reference in New Issue
Block a user