File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -228,13 +228,13 @@ void fx_BigInt_fromArrayBuffer(txMachine* the)
228228 sign = 1 ;
229229 if ((mxArgc > 2 ) && fxToBoolean (the , mxArgv (2 )))
230230 endian = EndianLittle ;
231- if (length == 0 ) {
231+ if (sign )
232+ length -- ;
233+ if (length <= 0 ) {
232234 mxResult -> value .bigint = gxBigIntNaN ;
233235 mxResult -> kind = XS_BIGINT_X_KIND ;
234236 return ;
235237 }
236- if (sign )
237- length -- ;
238238 bigint = fxBigInt_alloc (the , howmany (length , sizeof (txU4 )));
239239 bigint -> data [bigint -> size - 1 ] = 0 ;
240240 src = (txU1 * )(arrayBuffer -> value .arrayBuffer .address );
@@ -258,7 +258,7 @@ void fx_BigInt_fromArrayBuffer(txMachine* the)
258258 }
259259 }
260260 length = bigint -> size - 1 ;
261- while (bigint -> data [length ] == 0 )
261+ while (length && ( bigint -> data [length ] == 0 ) )
262262 length -- ;
263263 bigint -> size = length + 1 ;
264264 mxPullSlot (mxResult );
You can’t perform that action at this time.
0 commit comments