AshishYUO / huffman-compression

Huffman Compression Algorithm using C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Partial Compression in Certain Cases

Uttkarsh09 opened this issue · comments

For example if input file has the contents - "asdfasdfa", consider that 'a' has gotten "00" as its encoding, then in the code on line 270 where you check whether fch is empty or not, and accordingly write the partially filled byte to the file, will not satisfy the condition.

To reproduce the problem, compress a file with the same input ("asdfasdfa"). And then decompress, the contents of the decompressed file will not be the same.

Solution is to simply have a bool variable that ensures whether the contents have been written to the file or not.

Hi.

Thanks for pointing out the issue. I've merged the fix.