There was an error while loading. Please reload this page.
1 parent 6f055e7 commit daeffd2Copy full SHA for daeffd2
2 files changed
Lib/test/test_audioop.py
@@ -269,6 +269,11 @@ def test_lin2adpcm(self):
269
self.assertEqual(audioop.lin2adpcm(b'\0' * w * 10, w, None),
270
(b'\0' * 5, (0, 0)))
271
272
+ def test_invalid_adpcm_state(self):
273
+ # state must be a tuple or None, not an integer
274
+ self.assertRaises(TypeError, audioop.adpcm2lin, b'\0', 1, 555)
275
+ self.assertRaises(TypeError, audioop.lin2adpcm, b'\0', 1, 555)
276
+
277
def test_lin2alaw(self):
278
self.assertEqual(audioop.lin2alaw(datas[1], 1),
279
b'\xd5\x87\xa4\x24\xaa\x2a\x5a')
Modules/audioop.c
@@ -1525,6 +1525,9 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
1525
/* First time, it seems. Set defaults */
1526
valpred = 0;
1527
index = 0;
1528
+ } else if (!PyTuple_Check(state)) {
1529
+ PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
1530
+ goto exit;
1531
} else if (!PyArg_ParseTuple(state, "ii", &valpred, &index))
1532
goto exit;
1533
@@ -1631,6 +1634,9 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
1631
1634
1632
1635
1633
1636
1637
1638
1639
1640
1641
1642
0 commit comments