Fix #290: terminate g_buf correctly

This commit is contained in:
Arun Prakash Jana 2019-06-22 14:02:39 +05:30
parent a9392463b0
commit 4d6f304204
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 5 additions and 1 deletions

View File

@ -1887,7 +1887,11 @@ END:
clearprompt();
buf[len] = '\0';
wcstombs(g_buf, buf, CMD_LEN_MAX);
pos = wcstombs(g_buf, buf, CMD_LEN_MAX - 1);
if (pos >= CMD_LEN_MAX - 1)
g_buf[CMD_LEN_MAX - 1] = '\0';
free(buf);
return g_buf;
}