diff options
author | Oliver Kiddle <okiddle@yahoo.co.uk> | 2019-05-23 01:05:01 +0200 |
---|---|---|
committer | Oliver Kiddle <okiddle@yahoo.co.uk> | 2019-05-23 01:05:01 +0200 |
commit | a531a1ec2dce97c1507a45abd4795b1aea1edc9e (patch) | |
tree | 203061ecef2661089618926a0923a0aa213c33e5 /Src/text.c | |
parent | 3de2333b0821a1aaeb3ef98046212b5bf22b596c (diff) | |
download | zsh-a531a1ec2dce97c1507a45abd4795b1aea1edc9e.tar.gz zsh-a531a1ec2dce97c1507a45abd4795b1aea1edc9e.tar.xz zsh-a531a1ec2dce97c1507a45abd4795b1aea1edc9e.zip |
44345: fix wordcode traversal where ! without a following command could result in a crash
Diffstat (limited to 'Src/text.c')
-rw-r--r-- | Src/text.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Src/text.c b/Src/text.c index 3658b1bc6..a4191bf1a 100644 --- a/Src/text.c +++ b/Src/text.c @@ -470,8 +470,13 @@ gettext2(Estate state) " || " : " && "); s->code = *state->pc++; s->pop = (WC_SUBLIST_TYPE(s->code) == WC_SUBLIST_END); - if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_NOT) - taddstr("! "); + if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_NOT) { + if (WC_SUBLIST_SKIP(s->code) == 0) + stack = 1; + taddstr((stack || (!(WC_SUBLIST_FLAGS(s->code) & + WC_SUBLIST_SIMPLE) && wc_code(*state->pc) != + WC_PIPE)) ? "!" : "! "); + } if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_COPROC) taddstr("coproc "); } |