libheif
libheif copied to clipboard
Possible leak in x265 while decoding
Example code, relatively classic usage:
https://github.com/libgd/libgd/blob/master/src/gd_heif.c#L113
I can only reproduce using one of our tests (other do not have this leak):
https://github.com/libgd/libgd/blob/master/tests/heif/heif_im2im.c#L36
which reads using heif_context_read_from_memory_without_copy.
I am not completely sure where the allocations (2x leak):
================================================================= ==31634==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 2048 byte(s) in 2 object(s) allocated from: #0 0x7f049d924aa5 in posix_memalign (/lib/x86_64-linux-gnu/libasan.so.5+0x10eaa5) #1 0x7f049c33eb47 in x265::x265_malloc(unsigned long) (/lib/x86_64-linux-gnu/libx265.so.179+0x45db47)
SUMMARY: AddressSanitizer: 2048 byte(s) leaked in 2 allocation(s).
I also attached the valgrind log (ran it too), but there may be a lot of false positive, or a lot of other issues in x265 ;-)
I also get that one using decoding on reading from gdSurfaceCreateFromHeif (same file as above), in the vg_logfile_read.txt. vg_logfile_read.txt
Master and 1.12.0
may be related to https://github.com/strukturag/libheif/issues/531
Same in encoding
================================================================= ==32711==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 2048 byte(s) in 2 object(s) allocated from: #0 0x7f2f7c195aa5 in posix_memalign (/lib/x86_64-linux-gnu/libasan.so.5+0x10eaa5) #1 0x7f2f7ab92b47 in x265::x265_malloc(unsigned long) (/lib/x86_64-linux-gnu/libx265.so.179+0x45db47)
SUMMARY: AddressSanitizer: 2048 byte(s) leaked in 2 allocation(s).
Additional info, expected ;)
libde265_free_decoder or other are never used.
What was the idea or design behind it? As it may matter less in CLI apps, it is absolutely critical to free them in server environments. Happy to work on a PR however I would need to know what was the idea here :)
@pierrejoye Are you still seeing this problem?