-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #75917: SplFileObject::seek broken with CSV flags. #7697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.