Repository navigation
Fix Buffer deepEqual regression from prototype key comparison - #291
Merged
Merged
Conversation
The prototype-chain comparison added in 3fbe355 made deepEqual read inherited enumerable Buffer accessors such as `offset`. Two Buffer instances with identical bytes can still have different `offset` values because small Buffers are often views into different positions in the same pooled backing store. That offset is allocator metadata, not part of the logical buffer value. Keep prototype enumerable-key support for URL-like objects, but use own enumerable keys for array-like values so Buffer equality stays content-based.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #291 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 28 29 +1
Lines 532 1624 +1092
===========================================
+ Hits 532 1624 +1092
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
offsetreflects pooled backing-store layout rather than logical contentTest Plan
const assert = require('node:assert');
const deepEqual = require('./lib/deep-equal');
assert(deepEqual(Buffer.from('Hello'), Buffer.from('Hello')));
console.log('buffer reproduction passes');
NODE
fixes #289 and sinonjs/sinon#2678