mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters(). Reported by Ned Batchelder.
This commit is contained in:
parent
87a854dc73
commit
48d761e2b4
2 changed files with 5 additions and 8 deletions
|
@ -561,7 +561,6 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int wanted_fmt, wanted_channels, wanted_rate, strict=0;
|
int wanted_fmt, wanted_channels, wanted_rate, strict=0;
|
||||||
int fmt, channels, rate;
|
int fmt, channels, rate;
|
||||||
PyObject * rv; /* return tuple (fmt, channels, rate) */
|
|
||||||
|
|
||||||
if (!_is_fd_valid(self->fd))
|
if (!_is_fd_valid(self->fd))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -606,13 +605,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
|
||||||
|
|
||||||
/* Construct the return value: a (fmt, channels, rate) tuple that
|
/* Construct the return value: a (fmt, channels, rate) tuple that
|
||||||
tells what the audio hardware was actually set to. */
|
tells what the audio hardware was actually set to. */
|
||||||
rv = PyTuple_New(3);
|
return Py_BuildValue("(iii)", fmt, channels, rate);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -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.wSuiteMask));
|
||||||
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType));
|
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType));
|
||||||
|
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
Py_DECREF(version);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue