Skip to content

Fix Llama transform heap overflow for non-square tile size - #1097

Merged
sayanshaw24 merged 3 commits into
mainfrom
nebanfic/llama-heap-issue
Jul 29, 2026
Merged

Fix Llama transform heap overflow for non-square tile size#1097
sayanshaw24 merged 3 commits into
mainfrom
nebanfic/llama-heap-issue

Conversation

@nenad1002

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 27, 2026 16:52
@nenad1002
nenad1002 requested a review from a team as a code owner July 27, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Llama3ImageTransform image pre-processing path to prevent a heap out-of-bounds write when given a non-square tile size configuration, and adds a regression test/fixture to ensure invalid configs are rejected.

Changes:

  • Add validation in Llama3ImageTransform::Init() to reject non-square (and non-positive) tile sizes.
  • Add a defense-in-depth bounds check in DoPad() to prevent overrunning the padded image allocation.
  • Add a regression test and JSON fixture that attempts to create a processor with a non-square tile size.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/pp_api_test/test_processor.cc Adds a regression test ensuring non-square tile configs are rejected.
test/data/processor/mllama/llama_3_image_nonsquare.json Adds a failing processor configuration fixture with a non-square "size".
shared/api/image_transforms_mllama.hpp Adds safety checks in DoPad() and rejects non-square tile sizes in Init().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/pp_api_test/test_processor.cc
Comment thread shared/api/image_transforms_mllama.hpp
Comment thread shared/api/image_transforms_mllama.hpp Outdated
@sayanshaw24
sayanshaw24 enabled auto-merge (squash) July 29, 2026 18:03
@sayanshaw24
sayanshaw24 merged commit 05f545d into main Jul 29, 2026
38 checks passed
@sayanshaw24
sayanshaw24 deleted the nebanfic/llama-heap-issue branch July 29, 2026 18:23
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

Successfully merging this pull request may close these issues.

3 participants