commit eb1f05504023afbe115fc366b3455b6971e7bdc5
parent 812d6b6d43340bf6cd87be621838ea0db54d7793
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Sun, 4 May 2025 18:44:40 +0530
Add checks for return values
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -3022,10 +3022,14 @@ static int setfilter(regex_t *regex, const char *filter)
static int visible_re(const fltrexp_t *fltrexp, const char *fname)
{
#ifdef PCRE2
+ int r = 0;
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(fltrexp->pcre2x, NULL);
- int r = pcre2_match(fltrexp->pcre2x, (PCRE2_SPTR)fname, xstrlen(fname), 0, 0, match_data, NULL);
- pcre2_match_data_free(match_data);
+ if (match_data) {
+ r = pcre2_match(fltrexp->pcre2x, (PCRE2_SPTR)fname, xstrlen(fname), 0, 0, match_data, NULL);
+ pcre2_match_data_free(match_data);
+ }
+
return r > 0;
#else
return regexec(fltrexp->regex, fname, 0, NULL, 0) == 0;
@@ -7330,8 +7334,10 @@ nochange:
if (tmp) {
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(archive_pcre2, NULL);
- r = pcre2_match(archive_pcre2, (PCRE2_SPTR)tmp, pent->nlen - (tmp - pent->name) - 1, 0, 0, match_data, NULL);
- pcre2_match_data_free(match_data);
+ if (match_data) {
+ r = pcre2_match(archive_pcre2, (PCRE2_SPTR)tmp, pent->nlen - (tmp - pent->name) - 1, 0, 0, match_data, NULL);
+ pcre2_match_data_free(match_data);
+ }
} else
r = 0;