8000 Add a null-check on the return value of function getXTransitionStateByIndex by mugitya03 · Pull Request #39848 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a null-check on the return value of function getXTransitionStateByIndex #39848

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 2 commits into
base: master
Choose a base branch
from

Conversation

mugitya03
Copy link

Summary

The function getXTransitionStateByIndex may return nullptr if index is invalid. Inthe function updateXYCommand, the return value of getXTransitionStateByIndex is directly propagated to the function computeNewColor16uValue, where it is dereferenced without any validation.
I think it would be better to add a check on the return value of getXTransitionStateByIndex, as all other call sites have such checks.

Testing

Verified using static analysis and manual review:

  • Identified the issue with a static analyzer and confirmed it through code inspection.
  • Applied this patch and re-ran the analysis, confirming that the bug report no longer appears.

…yIndex

The function getXTransitionStateByIndex may return nullptr if index is invalid.
In function updateXYCommand, the return value of getXTransitionStateByIndex is directly propagated to function computeNewColor16uValue, where it is dereferenced without any validation.
I think it would be better to add a check on the return value of getXTransitionStateByIndex, as all other callsites have such checks.
Copy link
Contributor
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly identifies and fixes a potential null pointer dereference in updateXYCommand by adding checks for the return values of getXTransitionStateByIndex and getYTransitionStateByIndex. My review points out a critical issue where the wrong macro is used for the check, which would lead to a compilation error, and provides a suggestion for the correct macro to use.

Copy link
github-actions bot commented Jul 3, 2025

PR #39848: Size comparison from c4c6bea to 5aaedb9

Full report (2 builds for cc32xx)
platform target config section c4c6bea 5aaedb9 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 549470 549470 0 0.0
RAM 205144 205144 0 0.0
lock CC3235SF_LAUNCHXL FLASH 582590 582590 0 0.0
RAM 205344 205344 0 0.0

Copy link
Contributor
@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

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

Something is off here - this code is failing to compile ...

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mugitya03
Copy link
Author

Sorry, I may have mistakenly applied a Copilot suggestion while editing this code. Now it has been fixed.

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

Successfully merging this pull request may close these issues.

3 participants
0