@@ -1293,7 +1293,7 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
12931293 char * cp , * ncp ;
12941294 Py_ssize_t len ;
12951295 int chan , d , * prev_i , * cur_i , cur_o ;
1296- PyObject * samps , * str , * rv = NULL ;
1296+ PyObject * samps , * str , * rv = NULL , * channel ;
12971297 int bytes_per_frame ;
12981298
12991299 if (!audioop_check_size (width ))
@@ -1354,8 +1354,12 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
13541354 prev_i [chan ] = cur_i [chan ] = 0 ;
13551355 }
13561356 else {
1357+ if (!PyTuple_Check (state )) {
1358+ PyErr_SetString (PyExc_TypeError , "state must be a tuple or None" );
1359+ goto exit ;
1360+ }
13571361 if (!PyArg_ParseTuple (state ,
1358- "iO!;audioop. ratecv: illegal state argument" ,
1362+ "iO!;ratecv() : illegal state argument" ,
13591363 & d , & PyTuple_Type , & samps ))
13601364 goto exit ;
13611365 if (PyTuple_Size (samps ) != nchannels ) {
@@ -1364,10 +1368,18 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
13641368 goto exit ;
13651369 }
13661370 for (chan = 0 ; chan < nchannels ; chan ++ ) {
1367- if (!PyArg_ParseTuple (PyTuple_GetItem (samps , chan ),
1368- "ii:ratecv" , & prev_i [chan ],
1369- & cur_i [chan ]))
1371+ channel = PyTuple_GetItem (samps , chan );
1372+ if (!PyTuple_Check (channel )) {
1373+ PyErr_SetString (PyExc_TypeError ,
1374+ "ratecv(): illegal state argument" );
13701375 goto exit ;
1376+ }
1377+ if (!PyArg_ParseTuple (channel ,
1378+ "ii;ratecv(): illegal state argument" ,
1379+ & prev_i [chan ], & cur_i [chan ]))
1380+ {
1381+ goto exit ;
1382+ }
13711383 }
13721384 }
13731385
@@ -1638,7 +1650,9 @@ audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width,
16381650 PyErr_SetString (PyExc_TypeError , "state must be a tuple or None" );
16391651 return NULL ;
16401652 }
1641- else if (!PyArg_ParseTuple (state , "ii" , & valpred , & index )) {
1653+ else if (!PyArg_ParseTuple (state , "ii;lin2adpcm(): illegal state argument" ,
1654+ & valpred , & index ))
1655+ {
16421656 return NULL ;
16431657 }
16441658 else if (valpred >= 0x8000 || valpred < -0x8000 ||
@@ -1766,7 +1780,9 @@ audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width,
17661780 PyErr_SetString (PyExc_TypeError , "state must be a tuple or None" );
17671781 return NULL ;
17681782 }
1769- else if (!PyArg_ParseTuple (state , "ii" , & valpred , & index )) {
1783+ else if (!PyArg_ParseTuple (state , "ii;adpcm2lin(): illegal state argument" ,
1784+ & valpred , & index ))
1785+ {
17701786 return NULL ;
17711787 }
17721788 else if (valpred >= 0x8000 || valpred < -0x8000 ||
0 commit comments