mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-10 21:22:11 +00:00
[PR #896] [MERGED] Rar2 v20,v26 Multimedia (Audio) decoder fix #1318
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/896
Author: @Nanook
Created: 2/11/2025
Status: ✅ Merged
Merged: 2/12/2025
Merged by: @adamhathcock
Base:
master← Head:rar_unpack20_audio_fix📝 Commits (2)
c41888bRar2 v20,v26 Multimedia (Audio) decoder fix6bc690bSeriously?📊 Changes
1 file changed (+34 additions, -4 deletions)
View changed files
📝
src/SharpCompress/Compressors/Rar/UnpackV1/Unpack20.cs(+34 -4)📄 Description
This is a fix for the Audio Decoder in unpack20 (v20/v26). When decoding a rar that uses the old multimedia compression algorithm an error is raised:
This is because the MultiDecode[] objects are never instantiated.
private readonly MultDecode[] MD = new MultDecode[4];(Unpack20.cs:17)I looked back through the repo hoping to find and old working commit, but they have never been set. I even dug out the original Unrar project (pre SharpCompress) and that was the same.
Initialising them fixed the crash, but the decompression still wasn't correct. After many hours, I decided to compare the code with the C++ implementation used by 7zip and finally tracked it down to 2 bad casts in the Audio Decoder - (byte) when it should actually be (sbyte). Fortunately the rest of the code seemed to work perfectly after that (big relief).
I've not got any small archives that display this behaviour for use with unit tests. Current tests pass and this fix is being tested on many archives.
:-)
Edit: A combination of this fix and possibly Morilli's fix have fixed the remaining 170 ish archives that were failing to read. There's one outlier to investigate, but it may not be a sharpcompress issue :P
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.