Skip to content

Commit b470d9a

Browse files
Willian Gustavo Veigaweltling
authored andcommitted
Fix bug #67805 - SplFileObject setMaxLineLength.
1 parent 75c2aa9 commit b470d9a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS
20682068

20692069
if (intern->u.file.max_line_len > 0) {
20702070
buf = safe_emalloc((intern->u.file.max_line_len + 1), sizeof(char), 0);
2071-
if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len, &line_len) == NULL) {
2071+
if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len + 1, &line_len) == NULL) {
20722072
efree(buf);
20732073
buf = NULL;
20742074
} else {

ext/spl/tests/bug67805.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #67805 SplFileObject setMaxLineLength
3+
--CREDITS--
4+
Willian Gustavo Veiga <contact@willianveiga.com>
5+
--FILE--
6+
<?php
7+
$splFileObject = new SplFileObject(__FILE__);
8+
$splFileObject->setMaxLineLen(3);
9+
$line = $splFileObject->getCurrentLine();
10+
var_dump($line === '<?p');
11+
var_dump(strlen($line) === 3);
12+
?>
13+
--EXPECTF--
14+
bool(true)
15+
bool(true)

0 commit comments

Comments
 (0)