diff options
| author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2021-04-06 23:05:03 +0900 |
|---|---|---|
| committer | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2021-04-06 23:05:03 +0900 |
| commit | 0f62e07c802e3fa58d1199f34fcf9772da70c264 (patch) | |
| tree | a85aec1da2877c2c97439f5fac5b1b24692e1f94 /Src/math.c | |
| parent | users/26579: changes from review including parameter expansion to replace awk (diff) | |
| download | zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar.gz zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar.bz2 zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar.lz zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar.xz zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.tar.zst zsh-0f62e07c802e3fa58d1199f34fcf9772da70c264.zip | |
48389: getkeystring() should not return ptr to local var
Now it returns NULL if called with GETKEY_SINGLE_CHAR and next character
is not found. Caller must check the return value.
Diffstat (limited to 'Src/math.c')
| -rw-r--r-- | Src/math.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Src/math.c b/Src/math.c index b57ba42d4..1d0d86639 100644 --- a/Src/math.c +++ b/Src/math.c @@ -840,13 +840,18 @@ zzlex(void) if (*ptr == '#') { if (*++ptr == '\\' || *ptr == '#') { int v; + char *optr = ptr; ptr++; if (!*ptr) { zerr("bad math expression: character missing after ##"); return EOI; } - ptr = getkeystring(ptr, NULL, GETKEYS_MATH, &v); + if(!(ptr = getkeystring(ptr, NULL, GETKEYS_MATH, &v))) { + zerr("bad math expression: bad character after ##"); + ptr = optr; + return EOI; + } yyval.u.l = v; return NUM; } |
