From 4e80cf8bac2dd579486257d70e8b33be2b0ba659 Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Wed, 18 Jun 2008 10:05:29 +0000 Subject: [PATCH] MFH: Fix #45216 (Add a default size for fgetss) --- ext/spl/spl_directory.c | 7 ++++++- ext/spl/tests/bug45216.phpt | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext/spl/tests/bug45216.phpt diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index c0ddb9f1d4..9d1a71d56b 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2295,7 +2295,12 @@ SPL_METHOD(SplFileObject, fgetss) spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zval *arg2 = NULL; MAKE_STD_ZVAL(arg2); - ZVAL_LONG(arg2, intern->u.file.max_line_len); + + if (intern->u.file.max_line_len > 0) { + ZVAL_LONG(arg2, intern->u.file.max_line_len); + } else { + ZVAL_LONG(arg2, 1024); + } spl_filesystem_file_free_line(intern TSRMLS_CC); intern->u.file.current_line_num++; diff --git a/ext/spl/tests/bug45216.phpt b/ext/spl/tests/bug45216.phpt new file mode 100644 index 0000000000..b3c4aa51bf --- /dev/null +++ b/ext/spl/tests/bug45216.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::fgetss (bug 45216) +--CREDITS-- +Perrick Penet +#testfest phpcampparis 2008-06-07 +--FILE-- +text 1'); +$handle = fopen($file, 'r'); + +$object = new SplFileObject($file); +var_dump($object->fgetss()); +var_dump(fgetss($handle)); +?> +--CLEAN-- + +--EXPECTF-- +string(12) "text 0text 1" +string(12) "text 0text 1" -- 2.40.0