summaryrefslogtreecommitdiffstats
path: root/Modules/audioop.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r--Modules/audioop.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c
index dcd7788..80c8a2a 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1293,7 +1293,7 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
char *cp, *ncp;
Py_ssize_t len;
int chan, d, *prev_i, *cur_i, cur_o;
- PyObject *samps, *str, *rv = NULL;
+ PyObject *samps, *str, *rv = NULL, *channel;
int bytes_per_frame;
if (!audioop_check_size(width))
@@ -1354,8 +1354,12 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
prev_i[chan] = cur_i[chan] = 0;
}
else {
+ if (!PyTuple_Check(state)) {
+ PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
+ goto exit;
+ }
if (!PyArg_ParseTuple(state,
- "iO!;audioop.ratecv: illegal state argument",
+ "iO!;ratecv(): illegal state argument",
&d, &PyTuple_Type, &samps))
goto exit;
if (PyTuple_Size(samps) != nchannels) {
@@ -1364,10 +1368,18 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
goto exit;
}
for (chan = 0; chan < nchannels; chan++) {
- if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
- "ii:ratecv", &prev_i[chan],
- &cur_i[chan]))
+ channel = PyTuple_GetItem(samps, chan);
+ if (!PyTuple_Check(channel)) {
+ PyErr_SetString(PyExc_TypeError,
+ "ratecv(): illegal state argument");
goto exit;
+ }
+ if (!PyArg_ParseTuple(channel,
+ "ii;ratecv(): illegal state argument",
+ &prev_i[chan], &cur_i[chan]))
+ {
+ goto exit;
+ }
}
}
@@ -1638,7 +1650,9 @@ audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width,
PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
return NULL;
}
- else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
+ else if (!PyArg_ParseTuple(state, "ii;lin2adpcm(): illegal state argument",
+ &valpred, &index))
+ {
return NULL;
}
else if (valpred >= 0x8000 || valpred < -0x8000 ||
@@ -1766,7 +1780,9 @@ audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width,
PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
return NULL;
}
- else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
+ else if (!PyArg_ParseTuple(state, "ii;adpcm2lin(): illegal state argument",
+ &valpred, &index))
+ {
return NULL;
}
else if (valpred >= 0x8000 || valpred < -0x8000 ||