Sorry for the confusion, i meant "out of memory", not out of array bounds. I hope the following is better.
In _jswrap_interface_setTimeoutOrInterval, timerPtr is zero if there isn't enough memory. This might not have immediate consequences if all future ops align well (like jsvObjectSetChildAndUnLock). Or itemIndex may be zero despite a new timer. The consequences in this particular case may be negligible, so it may be just a bad example.
The main question is: care about "out of memory" (e.g. if (var) { ...; jsvUnLock(var); } all the way) because there is a sane future for the system after the incident, or don't and assume nothing bad will happen. Both viable imo.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sorry for the confusion, i meant "out of memory", not out of array bounds. I hope the following is better.
In
_jswrap_interface_setTimeoutOrInterval
,timerPtr
is zero if there isn't enough memory. This might not have immediate consequences if all future ops align well (likejsvObjectSetChildAndUnLock
). OritemIndex
may be zero despite a new timer. The consequences in this particular case may be negligible, so it may be just a bad example.Regarding
jsvObjectSetChildAndUnLock
: ifjsvObjectSetChildVar
returns zero due to "out of memory", it won't unlockchild
(https://github.com/espruino/Espruino/blob/7277a8dc9377e09f9a6837ff754e3dd8dd761563/src/jsvar.c#L3005). Compare withjsvArrayPushAndUnLock
wherevalue
is unlocked regardless (https://github.com/espruino/Espruino/blob/7277a8dc9377e09f9a6837ff754e3dd8dd761563/src/jsvar.c#L3298).The main question is: care about "out of memory" (e.g.
if (var) { ...; jsvUnLock(var); }
all the way) because there is a sane future for the system after the incident, or don't and assume nothing bad will happen. Both viable imo.