From 6444ec388c6b8a7a01418c5a9ffe595f6a9a2ee6 Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Wed, 18 Jun 2008 10:05:15 +0000 Subject: [PATCH] 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 74649b5bb6..74a3469561 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2427,7 +2427,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.50.1