Fix: Use an assert to make sure, an error message can be copied into buffer buf in mch_dirname().

The copied error message is NUL-terminated.
This commit is contained in:
oni-link
2014-03-07 18:04:15 +01:00
committed by Thiago de Arruda
parent 33eb031c01
commit 7f23ec398d

View File

@@ -33,10 +33,12 @@ int mch_chdir(char *path) {
*/
int mch_dirname(char_u *buf, int len)
{
assert(buf && len);
int errno;
if ((errno = uv_cwd((char *) buf, len)) != 0) {
STRCPY(buf, uv_strerror(errno));
return FAIL;
if ((errno = uv_cwd((char *)buf, len)) != 0) {
vim_strncpy(buf, (char_u *)uv_strerror(errno), len - 1);
return FAIL;
}
return OK;
}