]> granicus.if.org Git - php/commitdiff
Fixed #46053 (SplFileObject::seek - Endless loop)
authorArnaud Le Blanc <lbarnaud@php.net>
Thu, 11 Sep 2008 15:31:48 +0000 (15:31 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Thu, 11 Sep 2008 15:31:48 +0000 (15:31 +0000)
ext/spl/spl_directory.c
ext/spl/tests/bug46053.phpt [new file with mode: 0644]

index 40f196266a356ae8243389525047c8f235aa2a2b..1da3ae9f1fa6ce62a66d38e1a6071b9cb909e98f 100755 (executable)
@@ -2612,7 +2612,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 (file)
index 0000000..75da7f3
--- /dev/null
@@ -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"