summaryrefslogtreecommitdiff
path: root/src/diff_driver.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-04-10 09:36:38 +0200
committerPatrick Steinhardt <ps@pks.im>2015-04-10 09:40:33 +0200
commit129022ee1e16319c12f4d1607456c11e63182638 (patch)
treef061b4b7e63579f3b2f6c4c4285171df7c19da38 /src/diff_driver.c
parenta01d3a0b503559fe09519b787f353b25e52a0420 (diff)
downloadlibgit2-129022ee1e16319c12f4d1607456c11e63182638.tar.gz
Fix checking of return value for regcomp.
The regcomp function returns a non-zero value if compilation of a regular expression fails. In most places we only check for negative values, but positive values indicate an error, as well. Fix this tree-wide, fixing a segmentation fault when calling git_config_iterator_glob_new with an invalid regexp.
Diffstat (limited to 'src/diff_driver.c')
-rw-r--r--src/diff_driver.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 69eef0f7a..9d1337103 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -116,7 +116,7 @@ static int diff_driver_add_patterns(
if (error < 0)
break;
- if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) < 0) {
+ if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
/* if regex fails to compile, warn? fail? */
error = giterr_set_regex(&pat->re, error);
regfree(&pat->re);