mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
evbuffer_find fix from Dug Song
svn:r308
This commit is contained in:
parent
ba8289bea5
commit
de4e25f1d0
7
buffer.c
7
buffer.c
@ -432,12 +432,13 @@ evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len)
|
||||
u_char *search = buffer->buffer;
|
||||
u_char *p;
|
||||
|
||||
while ((p = memchr(search, *what, remain)) != NULL && remain >= len) {
|
||||
while ((p = memchr(search, *what, remain)) != NULL) {
|
||||
remain = buffer->off - (size_t)(search - buffer->buffer);
|
||||
if (remain < len)
|
||||
break;
|
||||
if (memcmp(p, what, len) == 0)
|
||||
return (p);
|
||||
|
||||
search = p + 1;
|
||||
remain = buffer->off - (size_t)(search - buffer->buffer);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user