diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-17 13:09:45 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-17 13:09:45 (GMT) |
commit | 15df36bb14e35489d841898069e3878f2144e48e (patch) | |
tree | d1b4122407f46de7b1a8263a8f20fbedbff7b3d8 | |
parent | 0585418b0d50755500587a887f3a901f8149cd00 (diff) | |
download | cpython-15df36bb14e35489d841898069e3878f2144e48e.zip cpython-15df36bb14e35489d841898069e3878f2144e48e.tar.gz cpython-15df36bb14e35489d841898069e3878f2144e48e.tar.bz2 |
Issue #16404: Add checks for return value of PyInt_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
-rw-r--r-- | Modules/ossaudiodev.c | 9 | ||||
-rw-r--r-- | Python/sysmodule.c | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index edf1a0e..284cc61 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -490,7 +490,6 @@ oss_setparameters(oss_audio_t *self, PyObject *args) { int wanted_fmt, wanted_channels, wanted_rate, strict=0; int fmt, channels, rate; - PyObject * rv; /* return tuple (fmt, channels, rate) */ if (!PyArg_ParseTuple(args, "iii|i:setparameters", &wanted_fmt, &wanted_channels, &wanted_rate, @@ -532,13 +531,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args) /* Construct the return value: a (fmt, channels, rate) tuple that tells what the audio hardware was actually set to. */ - rv = PyTuple_New(3); - if (rv == NULL) - return NULL; - PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt)); - PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels)); - PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate)); - return rv; + return Py_BuildValue("(iii)", fmt, channels, rate); } static int diff --git a/Python/sysmodule.c b/Python/sysmodule.c index fa66eb4..2c364af 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -616,6 +616,10 @@ sys_getwindowsversion(PyObject *self) PyStructSequence_SET_ITEM(version, pos++, PyInt_FromLong(ver.wSuiteMask)); PyStructSequence_SET_ITEM(version, pos++, PyInt_FromLong(ver.wProductType)); + if (PyErr_Occurred()) { + Py_DECREF(version); + return NULL; + } return version; } |