From b31933d93f562c5cff975c99332a2bd7a6a1265d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 17 Jul 2013 22:33:42 +0200 Subject: longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on small integers (0 or 1 digit) --- Objects/longobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Objects/longobject.c') 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)) -- cgit v1.2.1