diff Objects/unicodeobject.c @ 81587:974ace29ee2d 3.2

Issue #15989: Fix several occurrences of integer overflow when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
author Serhiy Storchaka <storchaka@gmail.com>
date Sat, 19 Jan 2013 12:26:26 +0200
parents 13cd78a2a17b
children 7625866f8127 8f10c9eae183
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Fri Jan 18 19:55:46 2013 +0200
+++ b/Objects/unicodeobject.c	Sat Jan 19 12:26:26 2013 +0200
@@ -9640,7 +9640,7 @@
                                     "* wants int");
                     goto onError;
                 }
-                width = PyLong_AsLong(v);
+                width = PyLong_AsSsize_t(v);
                 if (width == -1 && PyErr_Occurred())
                     goto onError;
                 if (width < 0) {
@@ -9677,7 +9677,7 @@
                                         "* wants int");
                         goto onError;
                     }
-                    prec = PyLong_AsLong(v);
+                    prec = _PyLong_AsInt(v);
                     if (prec == -1 && PyErr_Occurred())
                         goto onError;
                     if (prec < 0)