Fix #75917: SplFileObject::seek broken with CSV flags.#7697
Fix #75917: SplFileObject::seek broken with CSV flags.#7697Flashwade1990 wants to merge 2 commits intophp:PHP-8.0from
Conversation
|
Thank you for the PR! However, it seems this is rather fixing the symptoms than curing the disease, namely that normal reading frees the line before checking for EOF php-src/ext/spl/spl_directory.c Lines 1865 to 1867 in c2aea6e but CSV reading does not php-src/ext/spl/spl_directory.c Line 1939 in c2aea6e What about the following patch instead: ext/spl/spl_directory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index c7dd8b4721..045aad5bc1 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1939,6 +1939,8 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje
/* 1) use fgetcsv? 2) overloaded call the function, 3) do it directly */
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV) || intern->u.file.func_getCurr->common.scope != spl_ce_SplFileObject) {
+ spl_filesystem_file_free_line(intern);
+
if (php_stream_eof(intern->u.file.stream)) {
if (!silent) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Cannot read from file %s", intern->file_name); |
Thank you for checking @cmb69, the suggested approach is much better. I update the PR. |
cmb69
left a comment
There was a problem hiding this comment.
Thank you! This looks good to me, but I'd like a third pair of eyes reviewing this (after all, it's SPL …)
|
No further review, so I double-checked myself, and merged! Thanks again for the PR! |
No description provided.