Re: [whatwg/streams] Commit pull-into descriptors after filling from queue (PR #1326)

@MattiasBuelens commented on this pull request.



> +    if (SafeCopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset,
+                               bytesToCopy) === false) {
+      // This should never happen. Please report an issue if it does! https://github.com/whatwg/streams/issues
+      const e = new TypeError('Invalid buffer');
+      ReadableByteStreamControllerError(controller, e);
+      return false;
+    }

This check should *always* return `true`, so we can't write a test to check if an implementation correctly handles the case where it's `false`. That said, this check is our last chance to prevent a potential memory corruption bug.

Is it better to have a bit of untestable code here, or to only keep it as an assertion and hope that we don't break this again in the future? @domenic @saschanaz

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1326#pullrequestreview-2293726228
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1326/review/2293726228@github.com>

Received on Tuesday, 10 September 2024 20:40:25 UTC