From: Willian Gustavo Veiga Date: Sat, 6 Jun 2015 00:31:33 +0000 (-0300) Subject: Fix bug #67805 - SplFileObject setMaxLineLength. X-Git-Tag: php-5.5.27RC1~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b470d9a0d611bcaf91ab039e807891eda655f644;p=php Fix bug #67805 - SplFileObject setMaxLineLength. --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 34f0415b53..e20a80ae77 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2068,7 +2068,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS if (intern->u.file.max_line_len > 0) { buf = safe_emalloc((intern->u.file.max_line_len + 1), sizeof(char), 0); - if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len, &line_len) == NULL) { + if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len + 1, &line_len) == NULL) { efree(buf); buf = NULL; } else { diff --git a/ext/spl/tests/bug67805.phpt b/ext/spl/tests/bug67805.phpt new file mode 100644 index 0000000000..ba07b3da92 --- /dev/null +++ b/ext/spl/tests/bug67805.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #67805 SplFileObject setMaxLineLength +--CREDITS-- +Willian Gustavo Veiga +--FILE-- +setMaxLineLen(3); +$line = $splFileObject->getCurrentLine(); +var_dump($line === ' +--EXPECTF-- +bool(true) +bool(true)