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.schinde...@gmx.de>
---
 diffcore-pickaxe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 55067ca..88820b6 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -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)
-- 
2.10.0.windows.1.2.g732a511

Reply via email to