summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorGustavo Lopes <glopes@nebm.ist.utl.pt>2012-10-12 20:24:28 +0200
committerGustavo Lopes <glopes@nebm.ist.utl.pt>2012-10-12 20:24:28 +0200
commit2634f55992f28e95fe6ee41a40b9ede56639c1ce (patch)
tree392696c7040d7f8efdfa8fcb218ce7d87f130e5d /main/streams/streams.c
parent1d87ad89b24d8a1b992cb2dbc770fac6cfcc1fcb (diff)
parentf8e26d95f27779276a2dcf9d3aefb6b2b604ba63 (diff)
downloadphp-git-2634f55992f28e95fe6ee41a40b9ede56639c1ce.tar.gz
Merge branch 'PHP-5.4'
* PHP-5.4: Fix bug #63240 on stream_get_line()
Diffstat (limited to 'main/streams/streams.c')
-rw-r--r--main/streams/streams.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 81bf59446f..40b18e9f5b 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1055,9 +1055,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;
}