File tree 2 files changed +11
-13
lines changed
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) {
49
49
try {
50
50
return utf16 . decode ( wtf16 ) ;
51
51
} catch {
52
- let str = "" ;
53
- let off = 0 ;
54
- while ( len > STRING_CHUNKSIZE ) {
52
+ let str = "" , off = 0 ;
53
+ while ( len - off > STRING_CHUNKSIZE ) {
55
54
str += String . fromCharCode . apply ( String , wtf16 . subarray ( off , off += STRING_CHUNKSIZE ) ) ;
56
- len -= STRING_CHUNKSIZE ;
57
55
}
58
- return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off , off + len ) ) ;
56
+ return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off ) ) ;
59
57
}
60
58
}
61
59
Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ var loader = (function(exports) {
48
48
49
49
const STRING_CHUNKSIZE = 1024 ; // mitigate stack overflow
50
50
51
- const utf16 = new TextDecoder ( "utf-16le" ) ; // != wtf16
51
+ const utf16 = new TextDecoder ( "utf-16le" , {
52
+ fatal : true
53
+ } ) ; // != wtf16
52
54
53
55
/** Gets a string from memory. */
54
56
@@ -58,18 +60,16 @@ var loader = (function(exports) {
58
60
if ( len <= STRING_SMALLSIZE ) return String . fromCharCode . apply ( String , wtf16 ) ;
59
61
60
62
try {
61
- return utf16 . decode ( wtf16 , {
62
- fatal : true
63
- } ) ;
63
+ return utf16 . decode ( wtf16 ) ;
64
64
} catch {
65
- let str = "" , off = 0 ;
65
+ let str = "" ,
66
+ off = 0 ;
66
67
67
- while ( len > STRING_CHUNKSIZE ) {
68
+ while ( len - off > STRING_CHUNKSIZE ) {
68
69
str += String . fromCharCode . apply ( String , wtf16 . subarray ( off , off += STRING_CHUNKSIZE ) ) ;
69
- len -= STRING_CHUNKSIZE ;
70
70
}
71
71
72
- return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off , off + len ) ) ;
72
+ return str + String . fromCharCode . apply ( String , wtf16 . subarray ( off ) ) ;
73
73
}
74
74
}
75
75
/** Prepares the base module prior to instantiation. */
You can’t perform that action at this time.
0 commit comments