-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buffer: fix case of one buffer passed to concat
Fix Buffer.concat() so a copy is always returned regardless of the number of buffers that were passed. Previously if the array length was one then the same same buffer was returned. This created a special case for the user where there was a chance mutating the buffer returned by .concat() could mutate the buffer passed in. Also fixes an inconsistency when throwing if an array member was not a Buffer instance. For example: Buffer.concat([42]); // Returns 42 Buffer.concat([42, 1]); // Throws a TypeError Now .concat() will always throw if an array member is not a Buffer instance. See: #1891 PR-URL: #1937 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
11e4249
commit eea66e2
Showing
4 changed files
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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