GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: fix slice of slice of file-backed Blob · nodejs/node@ca68544

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/dataqueue
    • queue.cc
  • test/parallel
    • test-blob-file-backed.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/dataqueue/queue.cc‎

Copy file name to clipboardExpand all lines: src/dataqueue/queue.cc
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,9 @@ class FdEntry final : public EntryImpl {
840840
path_(std::move(path_)),
841841
stat_(stat),
842842
start_(start),
843-
end_(end) {}
843+
end_(end) {
844+
CHECK_LE(start, end);
845+
}
844846

845847
std::shared_ptr<DataQueue::Reader> get_reader() override {
846848
return ReaderImpl::Create(this);
@@ -851,7 +853,7 @@ class FdEntry final : public EntryImpl {
851853
uint64_t new_start = start_ + start;
852854
uint64_t new_end = end_;
853855
if (end.has_value()) {
854-
new_end = std::min(end.value(), end_);
856+
new_end = std::min(end.value() + start_, end_);
855857
}
856858

857859
CHECK(new_start >= start_);
Collapse file

‎test/parallel/test-blob-file-backed.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-blob-file-backed.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ writeFileSync(testfile5, '');
8686

8787
const res1 = blob.slice(995, 1005);
8888
strictEqual(await res1.text(), data.slice(995, 1005));
89+
90+
// Refs: https://github.com/nodejs/node/issues/53908
91+
for (const res2 of [
92+
blob.slice(995, 1005).slice(),
93+
blob.slice(995).slice(0, 10),
94+
blob.slice(0, 1005).slice(995),
95+
]) {
96+
strictEqual(await res2.text(), data.slice(995, 1005));
97+
}
98+
8999
await unlink(testfile2);
90100
})().then(common.mustCall());
91101

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.