Skip to content

Fixes binaryninja-api#6825 #6916

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: dev
Choose a base branch
from
Open

Fixes binaryninja-api#6825 #6916

wants to merge 1 commit into from

Conversation

plafosse
Copy link
Member

@plafosse plafosse commented Jun 3, 2025

we weren't handling zero offsets from structures at all it looks like.
#6825

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@plafosse plafosse requested review from rssor and Copilot June 24, 2025 13:10
Copy link

@Copilot Copilot AI left a comment

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 addresses issue binaryninja-api#6825 by refining the handling of zero offsets in structure member evaluation. Key changes include:

  • Replacing the dereference flag with a member resolution flag (memberResolved)
  • Updating token rendering logic to always use instr.size for type casts
  • Revising pointer arithmetic handling to only append arithmetic tokens when the offset is non-zero
Comments suppressed due to low confidence (3)

lang/c/pseudoc.cpp:2467

  • [nitpick] Consider renaming 'memberResolved' to 'isMemberResolved' for improved clarity and consistency with boolean naming conventions.
			bool memberResolved = false;

lang/c/pseudoc.cpp:2520

  • Ensure that always using 'instr.size' instead of conditionally selecting a size value is the intended design for the type cast, as this change may affect the formatting of the resulting expression.
				AppendSizeToken(instr.size, true, tokens);

lang/c/pseudoc.cpp:2536

  • Confirm that the decision to only append pointer arithmetic tokens when offset is non-zero fully addresses the zero offset issue without unintended side effects in pointer arithmetic scenarios.
			if (offset != 0)

* Accesses at offset zero were not handled.
* The pointer arithmetic and casts that were generated were incorrect
  in some cases.

Fixes #6825.
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.

2 participants