diff --git a/halloc_util.c b/halloc_util.c index f2eae06a9..3213fd70a 100644 --- a/halloc_util.c +++ b/halloc_util.c @@ -88,7 +88,7 @@ wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c ) { die_mem(); } - wcslcpy( res, in, c ); + wcslcpy( res, in, c+1 ); res[c] = L'\0'; return res; } diff --git a/wutil.c b/wutil.c index cc4368334..42be86718 100644 --- a/wutil.c +++ b/wutil.c @@ -1085,7 +1085,7 @@ wchar_t *wcsndup( const wchar_t *in, int c ) { die_mem(); } - wcsncpy( res, in, c ); + wcsncpy( res, in, c+1 ); res[c] = L'\0'; return res; }