diff options
author | rich cannings <richc@google.com> | 2010-08-31 15:19:38 -0700 |
---|---|---|
committer | rich cannings <richc@google.com> | 2010-08-31 15:19:38 -0700 |
commit | e44cb1a35c4bf3f30e2b9e3961c57b7ca6fa7849 (patch) | |
tree | a505afada0c66179cb978fd3c7694a50e67e3486 /libc | |
parent | 6a51defa034a1c033ed01f7de444c0a4fc615249 (diff) | |
download | bionic-e44cb1a35c4bf3f30e2b9e3961c57b7ca6fa7849.zip bionic-e44cb1a35c4bf3f30e2b9e3961c57b7ca6fa7849.tar.gz bionic-e44cb1a35c4bf3f30e2b9e3961c57b7ca6fa7849.tar.bz2 |
Fix return value.
Return a valid pointer (not NULL) when the character "c" is at the end of "src".
Change-Id: Iab0b677943f2c8a9fbb255c44689f5d6dc3535d7
Example:
memccpy(dest, "xzy", 'y', 3) should return dest+3 rather than null.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/string/memccpy.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/libc/string/memccpy.c b/libc/string/memccpy.c index 2689e80..789fde6 100644 --- a/libc/string/memccpy.c +++ b/libc/string/memccpy.c @@ -38,18 +38,9 @@ void *memccpy(void *dst, const void *src, int c, size_t n) for (;;) { if (ch == c || p >= p_end) break; *q++ = ch = *p++; - - if (ch == c || p >= p_end) break; - *q++ = ch = *p++; - - if (ch == c || p >= p_end) break; - *q++ = ch = *p++; - - if (ch == c || p >= p_end) break; - *q++ = ch = *p++; } - if (p >= p_end) + if (p >= p_end && ch != c) return NULL; return q; |