diff options
author | Gustavo Lopes <glopes@nebm.ist.utl.pt> | 2012-10-12 20:24:13 +0200 |
---|---|---|
committer | Gustavo Lopes <glopes@nebm.ist.utl.pt> | 2012-10-12 20:24:13 +0200 |
commit | f8e26d95f27779276a2dcf9d3aefb6b2b604ba63 (patch) | |
tree | 2a2d65750443c015c21bdf5a179964e767d4ef97 /main/streams/streams.c | |
parent | 9eff1a217885d9ea4750bdabd9d6ba88b2565e21 (diff) | |
parent | 76601c4fd1052bd46e8db4addb1bb9dd3b001f98 (diff) | |
download | php-git-f8e26d95f27779276a2dcf9d3aefb6b2b604ba63.tar.gz |
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
Fix bug #63240 on stream_get_line()
Diffstat (limited to 'main/streams/streams.c')
-rw-r--r-- | main/streams/streams.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index e9c2e07320..21ca72c6b5 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1060,9 +1060,17 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *re if (has_delim) { /* search for delimiter, but skip buffered_len (the number of bytes * buffered before this loop iteration), as they have already been - * searched for the delimiter */ + * searched for the delimiter. + * The left part of the delimiter may still remain in the buffer, + * so subtract up to <delim_len - 1> from buffered_len, which is + * the ammount of data we skip on this search as an optimization + */ found_delim = _php_stream_search_delim( - stream, maxlen, buffered_len, delim, delim_len TSRMLS_CC); + stream, maxlen, + buffered_len >= (delim_len - 1) + ? buffered_len - (delim_len - 1) + : 0, + delim, delim_len TSRMLS_CC); if (found_delim) { break; } |