Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode then Decode Crash #1168

Open
dukesook opened this issue May 7, 2024 · 0 comments
Open

Encode then Decode Crash #1168

dukesook opened this issue May 7, 2024 · 0 comments

Comments

@dukesook
Copy link
Contributor

dukesook commented May 7, 2024

When heif_context* doesn't read from a file, HeifFile::m_input_stream never initialized. Therefore, calling heif_decode_image() results in an unexpected Segmentation Fault.

  // Read HEIF
  heif_context* ctx_read = heif_context_alloc();
  heif_context_read_from_file(ctx_read, filename, nullptr);

  heif_image_handle* handle;
  heif_context_get_primary_image_handle(ctx_read, &handle);

  heif_image* img;
  heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGB, nullptr);

  // Write HEIF
  heif_encoder* encoder;
  heif_context* ctx_write = heif_context_alloc();
  heif_context_get_encoder_for_format(ctx_write, heif_compression_HEVC, &encoder);

  // 1. Encode image
  heif_context_encode_image(ctx_write, img, encoder, nullptr, &handle);

  // 2. Get image back
  heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGB, nullptr); // SEGFAULT

I would like this to work, or at least have struct heif_error catch it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant