diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 22:33:42 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 22:33:42 +0200 |
commit | b31933d93f562c5cff975c99332a2bd7a6a1265d (patch) | |
tree | 0844c4ef8ae69a8cbae0f440da12380a1790b304 /Objects/longobject.c | |
parent | 9b623aea7a1dec4d69c6c1b35b83e4769706213b (diff) | |
download | cpython-b31933d93f562c5cff975c99332a2bd7a6a1265d.tar.gz |
longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on
small integers (0 or 1 digit)
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index a894ec5a64..925e55a138 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -17,7 +17,8 @@ #endif /* convert a PyLong of size 1, 0 or -1 to an sdigit */ -#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)(x)->ob_digit[0] : \ +#define MEDIUM_VALUE(x) (assert(-1 <= Py_SIZE(x) && Py_SIZE(x) <= 1), \ + Py_SIZE(x) < 0 ? -(sdigit)(x)->ob_digit[0] : \ (Py_SIZE(x) == 0 ? (sdigit)0 : \ (sdigit)(x)->ob_digit[0])) #define ABS(x) ((x) < 0 ? -(x) : (x)) |