From 5aa019a0b58473f69742235d4b7a814d1d957872 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 22 Feb 2006 00:46:42 +1000 Subject: [PATCH] Fix off-by-one error resulting in truncated output from wcsndup fallback and halloc_wcsndup darcs-hash:20060221144642-ac50b-9dcd77238bc4bd740bbda6e15ded793fad44c363.gz --- halloc_util.c | 2 +- wutil.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; }