Skip to content

Commit 23ee87b

Browse files
committed
fix assert(0) if CRC32 called with nothing in debug build
1 parent 0aec54d commit 23ee87b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/jsvariterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ void jsvIteratorNew(JsvIterator *it, JsVar *obj, JsvIteratorFlags flags) {
774774
jsvStringIteratorNew(&it->it.str, obj, 0);
775775
} else {
776776
it->type = JSVI_NONE;
777-
assert(0);
777+
assert(0); // getting here won't break anything, but it's good to be warned about it
778778
}
779779
}
780780

src/jswrap_espruino.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,7 @@ Perform a standard 32 bit CRC (Cyclic redundancy check) on the supplied data
20332033
(one byte at a time) and return the result as an unsigned integer.
20342034
*/
20352035
JsVar *jswrap_espruino_CRC32(JsVar *data) {
2036+
if (!jsvIsIterable(data)) return 0; // fix assert(0) if called with nothing in debug build
20362037
JsvIterator it;
20372038
jsvIteratorNew(&it, data, JSIF_EVERY_ARRAY_ELEMENT);
20382039
uint32_t crc = 0xFFFFFFFF;

0 commit comments

Comments
 (0)