[Python-checkins] cpython (merge 3.3 -> default): Issue #16404: Add checks for return value of PyLong_FromLong() in
serhiy.storchaka
python-checkins at python.org
Tue Dec 17 14:15:22 CET 2013
http://hg.python.org/cpython/rev/d489394a73de
changeset: 88026:d489394a73de
parent: 88023:cf939f70d596
parent: 88025:928c0acf7c09
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Dec 17 15:12:46 2013 +0200
summary:
Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
files:
Modules/ossaudiodev.c | 9 +--------
Python/sysmodule.c | 4 ++++
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -564,7 +564,6 @@
{
int wanted_fmt, wanted_channels, wanted_rate, strict=0;
int fmt, channels, rate;
- PyObject * rv; /* return tuple (fmt, channels, rate) */
if (!_is_fd_valid(self->fd))
return NULL;
@@ -609,13 +608,7 @@
/* 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, PyLong_FromLong(fmt));
- PyTuple_SET_ITEM(rv, 1, PyLong_FromLong(channels));
- PyTuple_SET_ITEM(rv, 2, PyLong_FromLong(rate));
- return rv;
+ return Py_BuildValue("(iii)", fmt, channels, rate);
}
static int
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -801,6 +801,10 @@
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wSuiteMask));
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType));
+ if (PyErr_Occurred()) {
+ Py_DECREF(version);
+ return NULL;
+ }
return version;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list