mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
API: Bugfix: Use 0-terminated string in vim_strwidth
While the mb_string2cells function accepts a length parameter, it only seems to work properly with 0-terminated strings, since valgrind reports a conditional jump that depends on uninitialized values(means it reads after the string boundaries which could result in overflows or wrong results)
This commit is contained in:
parent
c6483aa2fa
commit
677d30d796
@ -73,7 +73,10 @@ Integer vim_strwidth(String str, Error *err)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mb_string2cells((char_u *)str.data, (int)str.size);
|
char *buf = xstrndup(str.data, str.size);
|
||||||
|
Integer rv = mb_string2cells((char_u *)buf, -1);
|
||||||
|
free(buf);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringArray vim_list_runtime_paths(void)
|
StringArray vim_list_runtime_paths(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user