1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-08-11 15:01:16 +02:00

38142: signal re-entrancy, maybe

This commit is contained in:
Barton E. Schaefer 2016-03-12 10:09:31 -08:00
parent b81b275ab3
commit ef6f1eb1c5
2 changed files with 23 additions and 5 deletions

View file

@ -49,6 +49,10 @@
* 38148: Completion/Unix/Command/_git: reflog: complete * 38148: Completion/Unix/Command/_git: reflog: complete
references next to commands references next to commands
2016-03-12 Barton E. Schaefer <schaefer@zsh.org>
* 38142: Src/pattern.c: signal re-entrancy, maybe
2016-03-11 Daniel Shahaf <d.s@daniel.shahaf.name> 2016-03-11 Daniel Shahaf <d.s@daniel.shahaf.name>
* 38135: Src/Zle/complete.c: internal: bin_compadd: Add a * 38135: Src/Zle/complete.c: internal: bin_compadd: Add a

View file

@ -537,9 +537,14 @@ patcompile(char *exp, int inflags, char **endexp)
Upat pscan; Upat pscan;
char *lng, *strp = NULL; char *lng, *strp = NULL;
Patprog p; Patprog p;
int savpatflags, savpatglobflags;
queue_signals(); queue_signals();
/* In case called from a signal handler before queuing */
savpatflags = patflags;
savpatglobflags = patglobflags;
startoff = sizeof(struct patprog); startoff = sizeof(struct patprog);
/* Ensure alignment of start of program string */ /* Ensure alignment of start of program string */
startoff = (startoff + sizeof(union upat) - 1) & ~(sizeof(union upat) - 1); startoff = (startoff + sizeof(union upat) - 1) & ~(sizeof(union upat) - 1);
@ -603,6 +608,8 @@ patcompile(char *exp, int inflags, char **endexp)
/* No, do normal compilation. */ /* No, do normal compilation. */
strp = NULL; strp = NULL;
if (patcompswitch(0, &flags) == 0) { if (patcompswitch(0, &flags) == 0) {
patflags = savpatflags;
patglobflags = savpatglobflags;
unqueue_signals(); unqueue_signals();
return NULL; return NULL;
} }
@ -738,6 +745,8 @@ patcompile(char *exp, int inflags, char **endexp)
if (endexp) if (endexp)
*endexp = patparse; *endexp = patparse;
patflags = savpatflags;
patglobflags = savpatglobflags;
unqueue_signals(); unqueue_signals();
return p; return p;
} }
@ -2259,6 +2268,9 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
char *progstr = (char *)prog + prog->startoff; char *progstr = (char *)prog + prog->startoff;
struct patstralloc patstralloc_struct; struct patstralloc patstralloc_struct;
/* In case called from a signal handler */
int savpatflags = patflags, savpatglobflags = patglobflags;
if (nump) { if (nump) {
maxnpos = *nump; maxnpos = *nump;
*nump = 0; *nump = 0;
@ -2302,7 +2314,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
* Either we are testing against a pure string, * Either we are testing against a pure string,
* or we can match anything at all. * or we can match anything at all.
*/ */
int ret, pstrlen; int pstrlen;
char *pstr; char *pstr;
if (patstralloc->alloced) if (patstralloc->alloced)
{ {
@ -2404,8 +2416,6 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
} }
} }
} }
return ret;
} else { } else {
int q = queue_signal_level(); int q = queue_signal_level();
@ -2441,6 +2451,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
} }
} }
if (!ret) { if (!ret) {
patflags = savpatflags;
patglobflags = savpatglobflags;
return 0; return 0;
} }
@ -2596,9 +2608,11 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin,
ret = 0; ret = 0;
restore_queue_signals(q); restore_queue_signals(q);
return ret;
} }
patflags = savpatflags;
patglobflags = savpatglobflags;
return ret;
} }
/* /*