diff options
author | Ambroise Vincent <ambroise.vincent@arm.com> | 2019-06-07 11:19:45 +0100 |
---|---|---|
committer | Ambroise Vincent <ambroise.vincent@arm.com> | 2019-06-20 09:59:24 +0100 |
commit | 294062fabf885c78d46e3c6e51963d5791b815b2 (patch) | |
tree | a23426668ea0b2a0c30e10ca1e370348f2c0f9f7 /lib/libc | |
parent | de3ad4f0963cdf5206a9736185d23514cfb45111 (diff) |
libc: fix memchr implementation
The previous implementation could behave incorrectly because of the sign
extension of the char when compared to the int.
Change-Id: I397838b0ec87a6f1af6972d022a8c19a5184b447
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/memchr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/memchr.c b/lib/libc/memchr.c index 0fe05358..8cbb7157 100644 --- a/lib/libc/memchr.c +++ b/lib/libc/memchr.c @@ -9,10 +9,10 @@ void *memchr(const void *src, int c, size_t len) { - const char *s = src; + const unsigned char *s = src; while (len--) { - if (*s == c) + if (*s == (unsigned char)c) return (void *) s; s++; } |