From: maartenbrock Date: Thu, 26 May 2005 08:29:18 +0000 (+0000) Subject: * device/lib/_strncpy.c: fixed not filling with \0 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4f0eb52f50f38d162e9d0c6bdf752deaf6084b6f;p=fw%2Fsdcc * device/lib/_strncpy.c: fixed not filling with \0 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3772 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index a7b3b35f..75393689 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-05-21 Maarten Brock + + * device/lib/_strncpy.c: fixed not filling with \0 + 2005-05-26 Erik Petrich * src/SDCCast.c (funcOfType, funcOfTypeVarg, stringToSymbol, diff --git a/device/lib/_strncpy.c b/device/lib/_strncpy.c index fd5f445c..2b7aa481 100644 --- a/device/lib/_strncpy.c +++ b/device/lib/_strncpy.c @@ -26,11 +26,13 @@ char *strncpy ( char * d, char * s, - size_t n ) + size_t n ) { register char * d1 = d; - while ( n-- ) + while ( n-- && *s ) *d++ = *s++ ; + while ( n-- ) + *d++ = '\0' ; return d1; }