File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed
Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,11 @@ function getStringImpl(buffer, ptr) {
4949 try {
5050 return utf16 . decode ( wtf16 ) ;
5151 } catch {
52- let str = "" ;
53- let off = 0 ;
54- while ( len > STRING_CHUNKSIZE ) {
52+ let str = "" , off = 0 ;
53+ while ( len - off > STRING_CHUNKSIZE ) {
5554 str += String . fromCharCode . apply ( String , wtf16 . subarray ( off , off += STRING_CHUNKSIZE ) ) ;
56- len -= STRING_CHUNKSIZE ;
5755 }
58- return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off , off + len ) ) ;
56+ return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off ) ) ;
5957 }
6058}
6159
Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ var loader = (function(exports) {
4848
4949 const STRING_CHUNKSIZE = 1024 ; // mitigate stack overflow
5050
51- const utf16 = new TextDecoder ( "utf-16le" ) ; // != wtf16
51+ const utf16 = new TextDecoder ( "utf-16le" , {
52+ fatal : true
53+ } ) ; // != wtf16
5254
5355 /** Gets a string from memory. */
5456
@@ -58,18 +60,16 @@ var loader = (function(exports) {
5860 if ( len <= STRING_SMALLSIZE ) return String . fromCharCode . apply ( String , wtf16 ) ;
5961
6062 try {
61- return utf16 . decode ( wtf16 , {
62- fatal : true
63- } ) ;
63+ return utf16 . decode ( wtf16 ) ;
6464 } catch {
65- let str = "" , off = 0 ;
65+ let str = "" ,
66+ off = 0 ;
6667
67- while ( len > STRING_CHUNKSIZE ) {
68+ while ( len - off > STRING_CHUNKSIZE ) {
6869 str += String . fromCharCode . apply ( String , wtf16 . subarray ( off , off += STRING_CHUNKSIZE ) ) ;
69- len -= STRING_CHUNKSIZE ;
7070 }
7171
72- return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off , off + len ) ) ;
72+ return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off ) ) ;
7373 }
7474 }
7575 /** Prepares the base module prior to instantiation. */
You can’t perform that action at this time.
0 commit comments