Skip to content

Commit c109439

Browse files
author
Patrick Soquet
committed
XS: secaudit issue #22
1 parent 4fefd3e commit c109439

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

xs/sources/xsBigInt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)