Fix overflow with parameters > LONG_MAX with Python 3.
The typemap incorrectly called PyInt_AsLong() if PyInt_Check() passed, but this check is the same as PyLong_Check() for Python 3 and so the correct PyLong_AsUnsignedLong() function was never called. As a consequence, passing any value greater than LONG_MAX (e.g. 0x87654321 on 32 bit architectures) to a function taking unsigned int, unsigned long or size_t parameter failed with an overflow error being generated. Fix this by simply disabling the part of the code dealing with PyInts for Python 3 as there is no distinction between PyInt and PyLong there any more. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13877 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ab7da898ef
commit
0ca11c8b6f
2 changed files with 8 additions and 1 deletions
|
|
@ -4,6 +4,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 2.0.9 (in progress)
|
Version 2.0.9 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2012-11-09: vzeitlin
|
||||||
|
[Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type.
|
||||||
|
|
||||||
2012-10-26: wsfulton
|
2012-10-26: wsfulton
|
||||||
Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously
|
Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously
|
||||||
the name was ignored during the typemap search. Applies to the following list of typemaps:
|
the name was ignored during the typemap search. Applies to the following list of typemaps:
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ SWIG_From_dec(unsigned long)(unsigned long value)
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
||||||
{
|
{
|
||||||
|
%#if PY_VERSION_HEX < 0x03000000
|
||||||
if (PyInt_Check(obj)) {
|
if (PyInt_Check(obj)) {
|
||||||
long v = PyInt_AsLong(obj);
|
long v = PyInt_AsLong(obj);
|
||||||
if (v >= 0) {
|
if (v >= 0) {
|
||||||
|
|
@ -117,7 +118,9 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
||||||
} else {
|
} else {
|
||||||
return SWIG_OverflowError;
|
return SWIG_OverflowError;
|
||||||
}
|
}
|
||||||
} else if (PyLong_Check(obj)) {
|
} else
|
||||||
|
%#endif
|
||||||
|
if (PyLong_Check(obj)) {
|
||||||
unsigned long v = PyLong_AsUnsignedLong(obj);
|
unsigned long v = PyLong_AsUnsignedLong(obj);
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
if (val) *val = v;
|
if (val) *val = v;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue