Skip to content

Commit

Permalink
Fix bug in template.js
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
mjackson committed Sep 9, 2024
1 parent 042608b commit ed05f23
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions parser/src/wasm/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function logger(context, raw) {
const len = Number(BigInt.asUintN(32, raw))
const ptr = Number(raw >> 32n)

console.error(textDecoder.decode(context.memory.buffer.subarray(ptr, ptr + len)))
console.error(textDecoder.decode(new Uint8Array(context.memory.buffer, ptr, len)))
}

function runCallback(context, type, parser, at, len) {
Expand Down Expand Up @@ -47,7 +47,7 @@ function parse(parser, data, limit) {
function fail(parser, code, description) {
const len = description.length
const ptr = this.alloc(len)
const buffer = this.memory.buffer.subarray(ptr, ptr + len)
const buffer = new Uint8Array(this.memory.buffer, ptr, len)
textEncoder.encodeInto(description, buffer)

this.fail(parser, code, ptr, len)
Expand Down Expand Up @@ -84,7 +84,7 @@ function getErrorDescription(parser) {
const len = Number(BigInt.asUintN(32, raw))
const ptr = Number(raw >> 32n)

return textDecoder.decode(this.memory.buffer.subarray(ptr, ptr + len))
return textDecoder.decode(new Uint8Array(this.memory.buffer, ptr, len))
}

function getCallbackError(state, parser) {
Expand Down

0 comments on commit ed05f23

Please sign in to comment.