ddiakopoulos / libnyquist

:microphone: Cross platform C++11 library for decoding audio (mp3, wav, ogg, opus, flac, etc)
BSD 2-Clause "Simplified" License
536 stars 64 forks source link

Revert implementation of musepack decoder (w/ heap corruption fix) #15

Closed r-lyeh-archived closed 8 years ago

r-lyeh-archived commented 8 years ago

This is the original decoder plus the minimal fix I've been able to implement.

I saw the destructor was leaking decoderMemory so I was going to fix it. Then I saw your new code had that inefficent memcpy and I wanted to get rid of it, so I took some more time to figure out what was going on with the heap corruption.

Now with your new code it was clear to me that the decoder needed some more extra padding space at the end (in fact, it is expecting to be at least MPC_DECODER_BUFFER_LENGTH/MPC_SAMPLE_FORMAT bytes) so I just reserved the vector properly, then resized it as it was meant to be (so the extra padding is left at the end for the decoder to overwrite).

Hope it is more clear now :)

TL;DR: the original source is kept, then only line at 125 was added

PS: It's ok if you dont want to merge this PR, but in that case dont forget to add delete decoderMemory; after mpc_demux_init() ! :smile:

r-lyeh-archived commented 8 years ago

Ty for fixing #13! :)

ddiakopoulos commented 8 years ago

Yeah... sorry about the leak -- debugging detritus. I'll hold off on the merge because I have a ton of little cleanups to do. The temporary buffer was also just a quick debugging test :)