aboutsummaryrefslogtreecommitdiffstats
path: root/regexp/jimregexp.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-02-12 03:51:16 +0000
committerNIIBE Yutaka <[email protected]>2020-02-12 03:51:16 +0000
commit29eb843fa52242627dec79840e6bc5be5ed98cc7 (patch)
treee0028ed51bb7273502eae9463aa84950cec9e9e2 /regexp/jimregexp.c
parentregexp: Fix use of regexp in g10/trustdb.c. (diff)
downloadgnupg-29eb843fa52242627dec79840e6bc5be5ed98cc7.tar.gz
gnupg-29eb843fa52242627dec79840e6bc5be5ed98cc7.zip
regexp: Check if ->pmatch != NULL.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'regexp/jimregexp.c')
-rw-r--r--regexp/jimregexp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/regexp/jimregexp.c b/regexp/jimregexp.c
index 2ea3a7d13..cab83b920 100644
--- a/regexp/jimregexp.c
+++ b/regexp/jimregexp.c
@@ -1214,12 +1214,16 @@ static int regtry( regex_t *preg, const char *string )
preg->reginput = string;
for (i = 0; i < preg->nmatch; i++) {
- preg->pmatch[i].rm_so = -1;
- preg->pmatch[i].rm_eo = -1;
+ if (preg->pmatch) {
+ preg->pmatch[i].rm_so = -1;
+ preg->pmatch[i].rm_eo = -1;
+ }
}
if (regmatch(preg, 1)) {
- preg->pmatch[0].rm_so = string - preg->start;
- preg->pmatch[0].rm_eo = preg->reginput - preg->start;
+ if (preg->pmatch) {
+ preg->pmatch[0].rm_so = string - preg->start;
+ preg->pmatch[0].rm_eo = preg->reginput - preg->start;
+ }
return(1);
} else
return(0);
@@ -1569,13 +1573,13 @@ static int regmatch(regex_t *preg, int prog)
if (regmatch(preg, next)) {
if (OP(preg, scan) < CLOSE) {
int no = OP(preg, scan) - OPEN;
- if (no < preg->nmatch && preg->pmatch[no].rm_so == -1) {
+ if (no < preg->nmatch && preg->pmatch && preg->pmatch[no].rm_so == -1) {
preg->pmatch[no].rm_so = save - preg->start;
}
}
else {
int no = OP(preg, scan) - CLOSE;
- if (no < preg->nmatch && preg->pmatch[no].rm_eo == -1) {
+ if (no < preg->nmatch && preg->pmatch && preg->pmatch[no].rm_eo == -1) {
preg->pmatch[no].rm_eo = save - preg->start;
}
}