summaryrefslogtreecommitdiff
path: root/Src/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/zpty.c14
-rw-r--r--Src/Modules/zutil.c20
2 files changed, 27 insertions, 7 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 0ef753915..2c87be16f 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -544,7 +544,8 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
p = dupstring(args[1]);
tokenize(p);
remnulargs(p);
- if (!(prog = patcompile(p, PAT_STATIC, NULL))) {
+ /* Signals handlers might stomp PAT_STATIC */
+ if (!(prog = patcompile(p, PAT_ZDUP, NULL))) {
zwarnnam(nam, "bad pattern: %s", args[1]);
return 1;
}
@@ -682,9 +683,14 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
write_loop(1, buf, used);
}
- if (seen && (!prog || matchok || !mustmatch))
- return 0;
- return cmd->fin + 1;
+ {
+ int ret = cmd->fin + 1;
+ if (seen && (!prog || matchok || !mustmatch))
+ ret = 0;
+ if (prog)
+ freepatprog(prog);
+ return ret;
+ }
}
static int
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c
index d95c0c254..19a8306b5 100644
--- a/Src/Modules/zutil.c
+++ b/Src/Modules/zutil.c
@@ -510,25 +510,33 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
zwarnnam(nam, "too many arguments");
return 1;
}
+
+ queue_signals(); /* Protect PAT_STATIC */
+
if (context) {
tokenize(context);
zstyle_contprog = patcompile(context, PAT_STATIC, NULL);
- if (!zstyle_contprog)
+ if (!zstyle_contprog) {
+ unqueue_signals();
return 1;
+ }
} else
zstyle_contprog = NULL;
if (stylename) {
s = (Style)zstyletab->getnode2(zstyletab, stylename);
- if (!s)
+ if (!s) {
+ unqueue_signals();
return 1;
+ }
zstyletab->printnode(&s->node, list);
} else {
scanhashtable(zstyletab, 1, 0, 0,
zstyletab->printnode, list);
}
+ unqueue_signals();
return 0;
}
switch (args[0][1]) {
@@ -675,14 +683,20 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
char **vals;
Patprog prog;
+ queue_signals(); /* Protect PAT_STATIC */
+
tokenize(args[3]);
if ((vals = lookupstyle(args[1], args[2])) &&
(prog = patcompile(args[3], PAT_STATIC, NULL))) {
while (*vals)
- if (pattry(prog, *vals++))
+ if (pattry(prog, *vals++)) {
+ unqueue_signals();
return 0;
+ }
}
+
+ unqueue_signals();
return 1;
}
break;