Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Fwd: New Defects reported by Coverity Scan for zsh



On 18 Oct, Bart Schaefer wrote:
> > *** CID 1547827:  Null pointer dereferences  (FORWARD_NULL)
> > /Src/Modules/pcre.c: 370 in bin_pcre_match()
> > >>>     Passing null pointer "named" to "zpcre_get_substrings", which dereferences it.
>
> This is from Oliver's 51738 (PCRE's alternative DFA), I'm not going to
> interpret futher.

The DFA matching doesn't support captures so I wouldn't expect it to
find any. However it counts them at compile time rather than when
matching so explicitly guarding against this condition probably is
needed.

Oliver

diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 96f3c6e65..f5cda6d38 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -187,7 +187,8 @@ zpcre_get_substrings(pcre2_code *pat, char *arg, pcre2_match_data *mdata,
 	    setaparam(substravar, matches);
 	}
 
-	if (!pcre2_pattern_info(pat, PCRE2_INFO_NAMECOUNT, &ncount) && ncount
+	if (namedassoc
+		&& !pcre2_pattern_info(pat, PCRE2_INFO_NAMECOUNT, &ncount) && ncount
 		&& !pcre2_pattern_info(pat, PCRE2_INFO_NAMEENTRYSIZE, &nsize)
 		&& !pcre2_pattern_info(pat, PCRE2_INFO_NAMETABLE, &ntable))
 	{




Messages sorted by: Reverse Date, Date, Thread, Author