kopia lustrzana https://github.com/micropython/micropython
lib/libc: Fix string0's implementation of strncpy.
Fixing 98e583430f
, the semantics of strncpy
require that the remainder of dst be filled with null bytes.
Signed-off-by: Damien George <damien@micropython.org>
pull/6270/head
rodzic
27767aafa2
commit
d9b7261024
|
@ -178,8 +178,10 @@ char *strncpy(char *s1, const char *s2, size_t n) {
|
|||
while (n > 0) {
|
||||
n--;
|
||||
if ((*dst++ = *src++) == '\0') {
|
||||
/* If we get here, we found a null character at the end of s2 */
|
||||
*dst = '\0';
|
||||
/* If we get here, we found a null character at the end
|
||||
of s2, so use memset to put null bytes at the end of
|
||||
s1. */
|
||||
memset(dst, '\0', n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue