diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c index 878e41919cbc..c457110b62d3 100644 --- a/lib/libc/string/memccpy.c +++ b/lib/libc/string/memccpy.c @@ -49,9 +49,10 @@ memccpy(t, f, c, n) if (n) { register unsigned char *tp = t; register const unsigned char *fp = f; + register unsigned char uc = c; do { - if ((*tp++ = *fp++) == c) - return (t); + if ((*tp++ = *fp++) == uc) + return (tp); } while (--n != 0); } return (0);