mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-15 05:16:30 +00:00
Fix wcsdup malloc size (#641)
Other wcs* function expect a full sizeof(wchar_t) NUL char at the end of the string.
This commit is contained in:
parent
3e0ddf70e9
commit
304cf8869c
1 changed files with 2 additions and 2 deletions
|
@ -25,6 +25,6 @@
|
|||
*/
|
||||
wchar_t *wcsdup(const wchar_t *s) {
|
||||
size_t len = wcslen(s);
|
||||
char *s2 = malloc(len * sizeof(wchar_t) + 1);
|
||||
return s2 ? memcpy(s2, s, len * sizeof(wchar_t) + 1) : NULL;
|
||||
char *s2 = malloc((len + 1) * sizeof(wchar_t));
|
||||
return s2 ? memcpy(s2, s, (len + 1) * sizeof(wchar_t)) : NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue