diff options
Diffstat (limited to 'py/binary.c')
-rw-r--r-- | py/binary.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/binary.c b/py/binary.c index d22e0f342d..6450478cc1 100644 --- a/py/binary.c +++ b/py/binary.c @@ -33,6 +33,7 @@ #include "py/binary.h" #include "py/smallint.h" #include "py/objint.h" +#include "py/runtime.h" // Helpers to work with binary-encoded data @@ -100,6 +101,11 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) { } } } + + if (size == 0) { + mp_raise_ValueError("bad typecode"); + } + if (palign != NULL) { *palign = align; } |