discord / lilliput

Resize images and animated GIFs in Go
https://discord.com/blog/how-discord-resizes-150-million-images-every-day-with-go-and-c
Other
1.94k stars 124 forks source link

fix webp memory leak #167

Closed remiolivier-discord closed 2 weeks ago

remiolivier-discord commented 2 weeks ago

When using webp_decoder_create and webp_decoder_release, valgrind detects a memory leak for a bitstream.

==959597== LEAK SUMMARY:
==959597==    definitely lost: 16,950 bytes in 1 blocks
==959597==    indirectly lost: 0 bytes in 0 blocks
==959597==      possibly lost: 0 bytes in 0 blocks
==959597==    still reachable: 62 bytes in 3 blocks
==959597==         suppressed: 0 bytes in 0 blocks

This fix solves the issue by deleting allocated data in the frame.bitstream

==959597== LEAK SUMMARY:
==959597==    definitely lost: 0 bytes in 1 blocks
==959597==    indirectly lost: 0 bytes in 0 blocks
==959597==      possibly lost: 0 bytes in 0 blocks
==959597==    still reachable: 62 bytes in 3 blocks
==959597==         suppressed: 0 bytes in 0 blocks