summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorArnaud Le Blanc <lbarnaud@php.net>2008-09-11 15:31:58 +0000
committerArnaud Le Blanc <lbarnaud@php.net>2008-09-11 15:31:58 +0000
commitc238cb8f848e574beeddf9ecaa6f9d49135fc518 (patch)
treebed743f21e24196a1bc89330365752a9d9dfcce6 /ext
parent7f5079ab3a14257a09561ddf28af2e15208b14bd (diff)
downloadphp-git-c238cb8f848e574beeddf9ecaa6f9d49135fc518.tar.gz
MFH: Fixed #46053 (SplFileObject::seek - Endless loop)
Diffstat (limited to 'ext')
-rwxr-xr-xext/spl/spl_directory.c4
-rw-r--r--ext/spl/tests/bug46053.phpt12
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 26c79b0dae..334e1dc6d3 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2469,7 +2469,9 @@ SPL_METHOD(SplFileObject, seek)
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
while(intern->u.file.current_line_num < line_pos) {
- spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
+ if (spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC) == FAILURE) {
+ break;
+ }
}
} /* }}} */
diff --git a/ext/spl/tests/bug46053.phpt b/ext/spl/tests/bug46053.phpt
new file mode 100644
index 0000000000..75da7f3bbf
--- /dev/null
+++ b/ext/spl/tests/bug46053.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #46053 (SplFileObject::seek - Endless loop)
+--FILE--
+<?php
+
+$x = new splfileobject(__FILE__);
+$x->getPathName();
+$x->seek(10);
+$x->seek(0);
+var_dump(trim($x->fgets()));
+--EXPECTF--
+string(%d) "<?php"