From d2be675575512794dcd41b9683b209fc15368154 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 4 Feb 2023 12:44:01 +0100 Subject: [PATCH] fix: bad buffer slice --- lib/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index 2dd689a6f09..496c568d732 100644 --- a/lib/client.js +++ b/lib/client.js @@ -363,7 +363,7 @@ async function lazyllhttp () { }, wasm_on_status: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) - const start = at - currentBufferPtr + const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_message_begin: (p) => { @@ -372,12 +372,12 @@ async function lazyllhttp () { }, wasm_on_header_field: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) - const start = at - currentBufferPtr + const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_header_value: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) - const start = at - currentBufferPtr + const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { @@ -386,7 +386,7 @@ async function lazyllhttp () { }, wasm_on_body: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) - const start = at - currentBufferPtr + const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_message_complete: (p) => {