From f49c3c98bc11f182122b00e70cfb17a07c784981 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 11 Sep 2008 15:31:48 +0000 Subject: [PATCH] Fixed #46053 (SplFileObject::seek - Endless loop) --- ext/spl/spl_directory.c | 4 +++- ext/spl/tests/bug46053.phpt | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 ext/spl/tests/bug46053.phpt diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 40f196266a3..1da3ae9f1fa 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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 index 00000000000..75da7f3bbfd --- /dev/null +++ b/ext/spl/tests/bug46053.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #46053 (SplFileObject::seek - Endless loop) +--FILE-- +getPathName(); +$x->seek(10); +$x->seek(0); +var_dump(trim($x->fgets())); +--EXPECTF-- +string(%d) "