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:
Johannes Schindelin
2016-09-05 14:29:47 +02:00
parent f899957fa7
commit a264f55769

View File

@@ -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, &regmatch, 0);
if (!two)