com php-src: Fix bug #67805 - SplFileObject setMaxLineLength.: ext/spl/spl_directory.c ext/spl/tests/bug67805 .phpt

From: Date: Mon, 08 Jun 2015 10:08:05 +0000
Subject: com php-src: Fix bug #67805 - SplFileObject setMaxLineLength.: ext/spl/spl_directory.c ext/spl/tests/bug67805 .phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87096@lists.php.net to get a copy of this message
Commit: b470d9a0d611bcaf91ab039e807891eda655f644 Author: Willian Gustavo Veiga <contact@willianveiga.com> Fri, 5 Jun 2015 21:31:33 -0300 Committer: Anatol Belski <ab@php.net> Mon, 8 Jun 2015 12:08:05 +0200 Parents: 75c2aa9d3a56576e08caf59319770f6984c0bc54 Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b470d9a0d611bcaf91ab039e807891eda655f644 Log: Fix bug #67805 - SplFileObject setMaxLineLength. Bugs: https://bugs.php.net/67805 Changed paths: M ext/spl/spl_directory.c A ext/spl/tests/bug67805.phpt Diff: diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 34f0415..e20a80a 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 0000000..ba07b3d --- /dev/null +++ b/ext/spl/tests/bug67805.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #67805 SplFileObject setMaxLineLength +--CREDITS-- +Willian Gustavo Veiga <contact@willianveiga.com> +--FILE-- +<?php +$splFileObject = new SplFileObject(__FILE__); +$splFileObject->setMaxLineLen(3); +$line = $splFileObject->getCurrentLine(); +var_dump($line === '<?p'); +var_dump(strlen($line) === 3); +?> +--EXPECTF-- +bool(true) +bool(true)

« previous php.cvs (#87096) next »