Commit b852d8c1 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by Serhiy Storchaka

[2.7] bpo-31848: Fix broken error handling in Aifc_read.initfp() when the SSND...

[2.7] bpo-31848: Fix broken error handling in Aifc_read.initfp() when the SSND chunk is not found (GH-5240) (GH-5781)

Initialize self._ssnd_chunk so that aifc.Error is raised as intended,
not AttributeError.
(cherry picked from commit 80d20b91)
Co-authored-by: default avatarZackery Spytz <zspytz@gmail.com>
parent 6c7edba1
......@@ -308,6 +308,7 @@ class Aifc_read:
else:
raise Error, 'not an AIFF or AIFF-C file'
self._comm_chunk_read = 0
self._ssnd_chunk = None
while 1:
self._ssnd_seek_needed = 1
try:
......
......@@ -214,6 +214,14 @@ class AIFCLowLevelTest(unittest.TestCase):
b = io.BytesIO('FORM' + struct.pack('>L', 4) + 'AIFF')
self.assertRaises(aifc.Error, aifc.open, b)
def test_read_no_ssnd_chunk(self):
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
b += b'COMM' + struct.pack('>LhlhhLL', 38, 0, 0, 0, 0, 0, 0)
b += b'NONE' + struct.pack('B', 14) + b'not compressed' + b'\x00'
with self.assertRaisesRegexp(aifc.Error, 'COMM chunk and/or SSND chunk'
' missing'):
aifc.open(io.BytesIO(b))
def test_read_wrong_compression_type(self):
b = 'FORM' + struct.pack('>L', 4) + 'AIFC'
b += 'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0)
......
......@@ -1345,6 +1345,7 @@ Nicholas Spies
Per Spilling
Joshua Spoerri
Noah Spurrier
Zackery Spytz
Nathan Srebro
RajGopal Srinivasan
Tage Stabell-Kulo
......
Fix the error handling in Aifc_read.initfp() when the SSND chunk is not found.
Patch by Zackery Spytz.
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