summaryrefslogtreecommitdiff
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-17 22:33:42 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-17 22:33:42 +0200
commitb31933d93f562c5cff975c99332a2bd7a6a1265d (patch)
tree0844c4ef8ae69a8cbae0f440da12380a1790b304 /Objects/longobject.c
parent9b623aea7a1dec4d69c6c1b35b83e4769706213b (diff)
downloadcpython-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.c3
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))