mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-12 23:01:16 -03:00
Fix for buffer overflows identified by libgmalloc
This commit is contained in:
22
fallback.cpp
22
fallback.cpp
@@ -1503,14 +1503,20 @@ static int mk_wcwidth(wchar_t ucs)
|
||||
|
||||
static int mk_wcswidth(const wchar_t *pwcs, size_t n)
|
||||
{
|
||||
int w, width = 0;
|
||||
|
||||
for (; *pwcs && n-- > 0; pwcs++)
|
||||
if ((w = mk_wcwidth(*pwcs)) < 0)
|
||||
return -1;
|
||||
else
|
||||
width += w;
|
||||
|
||||
int width = 0;
|
||||
for (size_t i=0; i < n; i++)
|
||||
{
|
||||
if (pwcs[i] == L'\0')
|
||||
break;
|
||||
|
||||
int w = mk_wcwidth(pwcs[i]);
|
||||
if (w < 0)
|
||||
{
|
||||
width = -1;
|
||||
break;
|
||||
}
|
||||
width += w;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user