-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-16477 (Segmentation fault when calling __debugInfo() after failed SplFileObject::__constructor) #16480
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
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.
LGTM!
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.
LGTM
ext/spl/spl_directory.c
Outdated
&use_include_path, &intern->u.file.zcontext) == FAILURE) { | ||
intern->u.file.open_mode = NULL; | ||
intern->file_name = NULL; | ||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|Sbr!", &intern->file_name, &open_mode, &use_include_path, &intern->u.file.zcontext) == FAILURE) { |
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.
intern->file_name
could be left with a dangling pointer if a later parameter fails to parse. This isn't currently an issue because new
will destroy the object, and ReflectionClass::newInstanceWithoutConstructor()
doesn't actually allow calling __construct
(prevented by spl_filesystem_object_get_method_check()
). Nonetheless, it might be preferable to store it to a variable and copy it to intern
when parsing is successful.
&intern->u.file.zcontext
doesn't really apply, since it's the last parameter, but for consistency it might still make sense.
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.
I've rewritten it so that it takes dedicated stack variables. However, the fact that intern->file_name
is not working on a copy seems quite dubious.
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.
Ok for me apart from the TODO that Ilija explained and my remark
…failed SplFileObject::__constructor)
15e23da
to
f639125
Compare
Also fix a memory leak when reinitializing SplFileTemp