]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #16404: Add checks for return value of PyLong_FromLong() in
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 17 Dec 2013 13:11:24 +0000 (15:11 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 17 Dec 2013 13:11:24 +0000 (15:11 +0200)
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.

Modules/ossaudiodev.c
Python/sysmodule.c

index 50e266f087f2e37256a4ae93d9d9780e226b9a17..817e20428c2f5dbf6c34546d9ef121d4157254cf 100644 (file)
@@ -561,7 +561,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 (!_is_fd_valid(self->fd))
         return NULL;
@@ -606,13 +605,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, 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
index 880385c9cbfc221aac019ea1493e68aff4a4dbdd..222630c1693df0080932834788a093c455be5001 100644 (file)
@@ -747,6 +747,10 @@ sys_getwindowsversion(PyObject *self)
     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;
 }