diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 20:33:42 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 20:33:42 (GMT) |
commit | 08a80b11adc86edb3a7eb186fc69bd27a8a9ea52 (patch) | |
tree | a38d742acf146775b0e2b1ed0f7763f15c344781 /Objects/longobject.c | |
parent | 8aed6f1c7d73dca2ef2b235e99d78a64f06e7d7a (diff) | |
download | cpython-08a80b11adc86edb3a7eb186fc69bd27a8a9ea52.zip cpython-08a80b11adc86edb3a7eb186fc69bd27a8a9ea52.tar.gz cpython-08a80b11adc86edb3a7eb186fc69bd27a8a9ea52.tar.bz2 |
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 a894ec5..925e55a 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)) |