libheif icon indicating copy to clipboard operation
libheif copied to clipboard

heif_context_read_from_reader bug?

Open dougkpowers opened this issue 2 years ago • 2 comments

I've got a HEIC image that will not load using LibHeifSharp. However, if I bind to libheif directly, i can get it to work.

Looking into the source, it appears that LibHeifSharp bindings only use the heif_context_read_from_reader method to load the content. If i use heif_context_read_from_file or heif_context_read_from_memory, it works just fine.

Specifically, when using heif_context_read_from_reader, the library aborts due to an assertion failure inside read_data of box.cc

I assume this is a bug within libheif and not a bug in LibHeifSharp. Let me know if you'd like a sample HEIC image.

dougkpowers avatar Jan 25 '22 22:01 dougkpowers

Both heif_context_read_from_file and heif_context_read_from_memory internally read from a reader object: https://github.com/strukturag/libheif/blob/d2b412553346c8cb057a9fe8a966a2471e732474/libheif/heif_file.cc#L80 https://github.com/strukturag/libheif/blob/d2b412553346c8cb057a9fe8a966a2471e732474/libheif/heif_file.cc#L87

Could you provide the full stack trace, ideally with variables? If reading with libheif works, it's probably a problem with the LibHeifSharp binding.

fancycode avatar Jan 26 '22 07:01 fancycode

I fixed a bug in the LibHeifSharp callback for heif_reader->read in version 2.2.0.

Requests to read zero bytes were failing due to incorrect parameter validation.

0xC0000054 avatar Mar 21 '22 03:03 0xC0000054

Is anything more required on this?

bradh avatar Jun 09 '23 07:06 bradh

No, it can be closed.

0xC0000054 avatar Jun 09 '23 23:06 0xC0000054