diff options
author | Peter Stephenson <pws@zsh.org> | 2016-10-20 10:43:52 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2016-10-20 10:43:52 +0100 |
commit | d2c9f85f59ab7e58af68c5f89b64a95ac26e1e43 (patch) | |
tree | a5a597222e99268817bf109be2a37bdb784890e7 | |
parent | b2d280038f97111144ce8aeb8ec293510b6b8e21 (diff) | |
download | zsh-d2c9f85f59ab7e58af68c5f89b64a95ac26e1e43.tar.gz zsh-d2c9f85f59ab7e58af68c5f89b64a95ac26e1e43.tar.xz zsh-d2c9f85f59ab7e58af68c5f89b64a95ac26e1e43.zip |
39683: Update scan pointers after possible alloc.
Problem could cause next scan index to point into an invalid block when handling meta characters.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/pattern.c | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 6e339b5ea..e7c7c8b07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-10-20 Peter Stephenson <p.stephenson@samsung.com> + + * 39683: Src/pattern.c: Update scan pointer in pattern after + possible reallocation for meta handling. + 2016-10-19 Barton E. Schaefer <schaefer@zsh.org> * 39680: Src/mem.c: correctly handle case of popping last arena diff --git a/Src/pattern.c b/Src/pattern.c index 4e2f2369f..158bfd560 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -669,12 +669,16 @@ patcompile(char *exp, int inflags, char **endexp) nmeta++; if (nmeta) { char *oldpatout = patout; + ptrdiff_t pd; patadd(NULL, 0, nmeta, 0); /* * Yuk. */ p = (Patprog)patout; - opnd = patout + (opnd - oldpatout); + pd = patout - oldpatout; + opnd += pd; + pscan += pd; + next += pd; dst = patout + startoff; } |