-
Notifications
You must be signed in to change notification settings - Fork 30k
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
buffer: zero-sized slices have .buffer but not .parent #8266
Comments
This seems weirdly intentional … @trevnorris ? |
@bnoordhuis That is intentional. It's backwards compatible with the pre-typed array implementation. Check it against v0.12. |
Huh, you're right. It's weird because v0.10 doesn't work like that. Was that an intentional change in v0.12? I can't think of a plausible reason why someone would want it to work like that, it goes against the principle of least surprise. |
Yeah, I've also found this to be a bit odd. @trevnorris does it still have to be this way? What breaks otherwise? |
@bnoordhuis Change happened b/c of an optimization I implemented, and while writing the change making sure a zero-slice was pointing to its parent was neither documented nor tested. So must have slipped through. @jasnell Since this change has been around for so long and this is the first bug report based on the change, and also because the use of |
If the Buffer object's length is zero, or equal to the underlying buffer object's length, `parent` property returns `undefined`. > new Buffer(0).parent undefined > new Buffer(Buffer.poolSize).parent undefined This patch makes the buffer objects to consistently expose the buffer object via the `parent` property, always. Fixes: nodejs#8266
Something that tripped me up earlier today. With master:
The text was updated successfully, but these errors were encountered: