diff --git a/ChangeLog b/ChangeLog index 2bac81fc4..e6a2c2f76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ - Handle out of memory errors in jsvCreateNewChild - Do not garbage collect inside an IRQ On nRF52 devices, allow button press at boot to clear out peer manager data + Work out length of typed array with offset correctly (fix #1204) 1v93 : Ensure that specifying too many advertising UUIDs causes an exception, not a reboot nRF5x: Fix for time jump caused by reentrancy in jshGetSystemTime diff --git a/src/jswrap_arraybuffer.c b/src/jswrap_arraybuffer.c index 61bce3d95..827672fc8 100644 --- a/src/jswrap_arraybuffer.c +++ b/src/jswrap_arraybuffer.c @@ -337,7 +337,10 @@ JsVar *jswrap_typedarray_constructor(JsVarDataArrayBufferViewType type, JsVar *a jsExceptionHere(JSET_ERROR, "Unsupported first argument of type %t\n", arr); return 0; } - if (length==0) length = (JsVarInt)(jsvGetArrayBufferLength(arrayBuffer) / JSV_ARRAYBUFFER_GET_SIZE(type)); + if (length==0) { + length = (JsVarInt)((jsvGetArrayBufferLength(arrayBuffer)-byteOffset) / JSV_ARRAYBUFFER_GET_SIZE(type)); + if (length<0) length=0; + } JsVar *typedArr = jsvNewWithFlags(JSV_ARRAYBUFFER); if (typedArr) { typedArr->varData.arraybuffer.type = type;