Kaydet (Commit) 1a664419 authored tarafından Facundo Batista's avatar Facundo Batista

Issue 3306. Better control for a lenght in findmax() function.

üst 10cf7d94
......@@ -161,6 +161,10 @@ class TestAudioop(unittest.TestCase):
self.assertEqual(audioop.getsample(data[1], 2, i), i)
self.assertEqual(audioop.getsample(data[2], 4, i), i)
def test_negavitelen(self):
# from issue 3306, previously it segfaulted
self.assertRaises(audioop.error,
audioop.findmax, ''.join( chr(x) for x in xrange(256)), -2392392)
def test_main():
run_unittest(TestAudioop)
......
......@@ -575,7 +575,7 @@ audioop_findmax(PyObject *self, PyObject *args)
}
len1 >>= 1;
if ( len1 < len2 ) {
if ( len2 < 0 || len1 < len2 ) {
PyErr_SetString(AudioopError, "Input sample should be longer");
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment