]> granicus.if.org Git - php/commitdiff
Fix bug #67805 - SplFileObject setMaxLineLength.
authorWillian Gustavo Veiga <contact@willianveiga.com>
Sat, 6 Jun 2015 00:31:33 +0000 (21:31 -0300)
committerAnatol Belski <ab@php.net>
Mon, 8 Jun 2015 10:08:05 +0000 (12:08 +0200)
ext/spl/spl_directory.c
ext/spl/tests/bug67805.phpt [new file with mode: 0644]

index 34f0415b53348e9f368ce1411778c8da1366fdb9..e20a80ae77c6e98b2f2c1371d9b0547e73e5347a 100644 (file)
@@ -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 (file)
index 0000000..ba07b3d
--- /dev/null
@@ -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)