Commit 294062fa authored by Ambroise Vincent's avatar Ambroise Vincent

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: default avatarAmbroise Vincent <>
parent de3ad4f0
......@@ -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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment