diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-01-17 22:50:20 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-01-17 22:53:06 +0300 |
commit | af9046193148084f008501434e4c9f49fedc053f (patch) | |
tree | 7a05a10f74c645a5154f877c14eebbae25bd45f3 /py/binary.c | |
parent | 5e80c53c115e8b45df598ffdbc45dfdd543be8ac (diff) |
py/binary: mp_binary_get_size: Raise error on unsupported typecodes.
Previouly, we had errors checked in callers, which led to duplicate code
or missing checks in some places.
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 d22e0f342..6450478cc 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; } |