Fix integer multiplication overflow in jellyfish lake density rendering#15
Merged
highperformancecoder merged 2 commits intoJul 18, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix code scanning alert 384 and address false positives
Fix integer multiplication overflow in jellyfish lake density rendering
Jul 18, 2026
highperformancecoder
marked this pull request as ready for review
July 18, 2026 07:48
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential integer-overflow bug in lake_t::draw_density() when allocating the pixel buffer for density rendering, by widening the multiplication used to compute the vector size so it can’t overflow in 32-bit unsigned arithmetic on large canvases.
Changes:
- Widen
3*width*heighttosize_tarithmetic by casting the leading literal tosize_tin theppbuffer allocation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
3*width*heightinjellyfish.ccperforms all arithmetic inunsigned int, risking overflow before the result is widened tosize_tfor thevectorconstructor — a problem on large canvases wherewidth*heightexceeds 2³²/3 ≈ 1.4 billion.Change
Cast the leading literal to
size_tso the entire multiplication chain runs in 64-bit arithmetic:Addresses CodeQL alert
cpp/integer-multiplication-cast-to-long(#384).This change is