mailing list of musl libc
 help / color / mirror / code / Atom feed
* A small bug in strrchr
@ 2012-05-26 21:05 Richard Pennington
  2012-05-26 22:06 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Pennington @ 2012-05-26 21:05 UTC (permalink / raw)
  To: musl

Hi,

I found a small bug in strrchr(). 

strrchr("string", '\0') does not return a pointer to the trailing nul byte.

Here is the corrected version:


#include <string.h>

void *__memrchr(const void *, int, size_t);

char *strrchr(const char *s, int c)
{
        return __memrchr(s, c, strlen(s) + 1);
}

(I added the + 1)

-Rich



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-26 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-26 21:05 A small bug in strrchr Richard Pennington
2012-05-26 22:06 ` Rich Felker
2012-05-26 22:12   ` Richard Pennington
2012-05-26 22:40     ` Szabolcs Nagy
2012-05-26 22:50       ` Richard Pennington

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).