From a0abee140b4927a389afc6f5804bb9230b1f8cf3 Mon Sep 17 00:00:00 2001 From: Qiushi Pan <17402261+qqhann@users.noreply.github.com> Date: Mon, 12 Jul 2021 23:03:00 +0900 Subject: [PATCH 1/2] Update DictionaryLoader.js Fix: prevent load error for array buffer by using DataView --- src/loader/DictionaryLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/DictionaryLoader.js b/src/loader/DictionaryLoader.js index 5f88c0b..618c8c1 100644 --- a/src/loader/DictionaryLoader.js +++ b/src/loader/DictionaryLoader.js @@ -114,7 +114,7 @@ DictionaryLoader.prototype.load = function (load_callback) { var unk_pos_buffer = new Uint8Array(buffers[1]); var unk_map_buffer = new Uint8Array(buffers[2]); var cat_map_buffer = new Uint8Array(buffers[3]); - var compat_cat_map_buffer = new Uint32Array(buffers[4]); + var compat_cat_map_buffer = new DataView(buffers[4]).setUint32(); var invoke_def_buffer = new Uint8Array(buffers[5]); dic.loadUnknownDictionaries(unk_buffer, unk_pos_buffer, unk_map_buffer, cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer); From 0e46b467135750b7562a5c244b03814aca42aaf2 Mon Sep 17 00:00:00 2001 From: Qiushi Pan <17402261+qqhann@users.noreply.github.com> Date: Tue, 13 Jul 2021 02:31:36 +0900 Subject: [PATCH 2/2] Update DictionaryLoader.js Fix: was not using DataView correctly. --- src/loader/DictionaryLoader.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/loader/DictionaryLoader.js b/src/loader/DictionaryLoader.js index 618c8c1..6a5719c 100644 --- a/src/loader/DictionaryLoader.js +++ b/src/loader/DictionaryLoader.js @@ -114,7 +114,11 @@ DictionaryLoader.prototype.load = function (load_callback) { var unk_pos_buffer = new Uint8Array(buffers[1]); var unk_map_buffer = new Uint8Array(buffers[2]); var cat_map_buffer = new Uint8Array(buffers[3]); - var compat_cat_map_buffer = new DataView(buffers[4]).setUint32(); + var byteLength = buffers[4].byteLength; + var alignment = Uint32Array.BYTES_PER_ELEMENT; + var alignedLength = byteLength - (byteLength % alignment); + var alignedBuffer = buffers[4].slice(0, alignedLength); + var compat_cat_map_buffer = new Uint32Array(alignedBuffer); var invoke_def_buffer = new Uint8Array(buffers[5]); dic.loadUnknownDictionaries(unk_buffer, unk_pos_buffer, unk_map_buffer, cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer);