buffer: combine checking range of sourceStart in `buf.copy` · nodejs/node@e457d89 · GitHub
Skip to content

Commit e457d89

Browse files
deokjinkimtargos
authored andcommitted
buffer: combine checking range of sourceStart in buf.copy
Merging 2 checking range of sourceStart into 1. Plus, add test case to increase coverage if sourceStart is greater than length of source. PR-URL: #47758 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1b06c1e commit e457d89

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

lib/buffer.js

Lines changed: 2 additions & 8 deletions

test/parallel/test-buffer-alloc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ b.copy(Buffer.alloc(0), 1, 1, 1);
124124
b.copy(Buffer.alloc(1), 1, 1, 1);
125125

126126
// Try to copy 0 bytes from past the end of the source buffer
127-
b.copy(Buffer.alloc(1), 0, 2048, 2048);
127+
b.copy(Buffer.alloc(1), 0, 1024, 1024);
128128

129129
// Testing for smart defaults and ability to pass string values as offset
130130
{

test/parallel/test-buffer-copy.js

Lines changed: 9 additions & 2 deletions

0 commit comments

Comments
 (0)