Skip to content

Fix(MemoryTrunk.DefragTwoRegion): Unsigned difference expression compared to zero #385

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

odaysec
Copy link

@odaysec odaysec commented May 28, 2025

(hole_right_offset >= (uint32_t)_bwd_cell_offset && (hole_right_offset - _bwd_cell_offset - _bwd_cell_size > 0)) ||

Fix the issue the result of the subtraction hole_right_offset - _bwd_cell_offset - _bwd_cell_size should be cast to a signed type (e.g., int64_t) before performing the comparison. This ensures that the subtraction can produce negative values, and the comparison > 0 will behave as intended.

Steps to fix:

  1. Cast the result of the subtraction to int64_t before performing the comparison.
  2. Ensure that the cast does not affect other parts of the code or introduce unintended side effects.

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