Prevent array index out of bounds for symbol

Bug-Debian: https://github.com/tats/w3m/issues/38
This commit is contained in:
Tatsuya Kinoshita
2016-11-14 21:01:08 +09:00
parent 5b932eb715
commit 0c3f5d0e0d
4 changed files with 8 additions and 7 deletions

View File

@@ -176,10 +176,10 @@ push_symbol(Str str, char symbol, int width, int n)
#ifdef USE_M17N
if (width == 2)
p = alt2_symbol[(int)symbol];
p = alt2_symbol[(unsigned char)symbol % N_SYMBOL];
else
#endif
p = alt_symbol[(int)symbol];
p = alt_symbol[(unsigned char)symbol % N_SYMBOL];
for (i = 0; i < 2 && *p; i++, p++)
buf[i] = (*p == ' ') ? NBSP_CODE : *p;