mirror of git://git.code.sf.net/p/zsh/code
35854: ensure history character unget doesn't recurse infinitely
This commit is contained in:
parent
9a82a86757
commit
49ff2e00dc
|
@ -1,5 +1,8 @@
|
|||
2015-07-23 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 35854: Stc/hist.c: ensure character unget doesn't cause
|
||||
infinite recursion.
|
||||
|
||||
* 35793: Src/zsh.h: avoid undefined behaviour shifting signed
|
||||
number.
|
||||
|
||||
|
|
10
Src/hist.c
10
Src/hist.c
|
@ -136,6 +136,7 @@ mod_export int hist_skip_flags;
|
|||
#define HA_NOINC (1<<1) /* Don't store, curhist not incremented */
|
||||
#define HA_INWORD (1<<2) /* We're inside a word, don't add
|
||||
start and end markers */
|
||||
#define HA_UNGET (1<<3) /* Recursively ungetting */
|
||||
|
||||
/* Array of word beginnings and endings in current history line. */
|
||||
|
||||
|
@ -904,8 +905,13 @@ ihungetc(int c)
|
|||
|
||||
while (!lexstop && !errflag) {
|
||||
if (hptr[-1] != (char) c && stophist < 4 &&
|
||||
hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\')
|
||||
hungetc('\n'), hungetc('\\');
|
||||
hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\' &&
|
||||
!(histactive & HA_UNGET)) {
|
||||
histactive |= HA_UNGET;
|
||||
hungetc('\n');
|
||||
hungetc('\\');
|
||||
histactive &= ~HA_UNGET;
|
||||
}
|
||||
|
||||
if (expanding) {
|
||||
zlemetacs--;
|
||||
|
|
Loading…
Reference in New Issue