Skip to content

LibJpegWrap follow-ups from the review of #2 (Rgb24 codec) #3

Open

Description

@rafalmaciag

These came up in the review of #2 and were left for later:

  1. Line endings: src/LibJpegWrap/LibJpegWrap.cpp changed from CRLF to LF in Rgb24 JPEG decode/encode in LibJpegWrap and JpegCodec (for v1.5.0) #2, so its diff is a whole-file rewrite. Decide on a line ending for the file (.gitattributes) and normalise it.
  2. Possible double free on the encode error path: in EncodeRgb24, if libjpeg-turbo's jpeg_mem_dest has grown its buffer and an error then longjmps out, free(mem) may free a buffer that empty_mem_output_buffer already freed. The caller's mem is only updated in term_destination. Track the current buffer explicitly, or use a custom destination manager over the caller's buffer.
  3. A truncated scan decodes as success: libjpeg treats premature end of data as a warning and fills the rest with gray, so DecodeRgb24 (and the Gray8/I420 decoders) return a full frame. Consider failing when num_warnings > 0, or exposing the warning count.
  4. int overflow on huge sizes: MaxJpegSize uses checked and throws, but width * height * 3 in DecodeRgb24 (and FrameHeader lengths elsewhere) can overflow int for very large images. Validate the dimensions before allocating.

Also outside this list: the linux-arm64 and win-x64 LibJpegWrap binaries lack the Rgb24 exports, so the managed calls throw NotSupportedException there until those binaries are rebuilt.

🤖 Generated with Claude Code

https://claude.ai/code/session_014wH5aL3TZhJNvLqa8YTku8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions