Skip to content

Fix #10526 FP: negativeIndex if function call is made after index check#4052

Merged
orbitcowboy merged 4 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix10526
Apr 27, 2022
Merged

Fix #10526 FP: negativeIndex if function call is made after index check#4052
orbitcowboy merged 4 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix10526

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/valueflow.cpp Outdated
// Assume library function doesn't modify user-global variables
return Action::None;
// Function cast does not modify global variables
} else if (Token::simpleMatch(tok->astParent(), ".") && tok->astParent()->astOperand1() && tok->astParent()->astOperand1()->variable() &&
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.

We shouldn't do tok->astParent()->astOperand1()->variable() as containers can be arbitrary expressions. Can you just do astIsContainer(tok->astParent()->astOperand1())?

@orbitcowboy orbitcowboy merged commit bcbc29a into cppcheck-opensource:main Apr 27, 2022
@chrchr-github chrchr-github deleted the chr_Fix10526 branch October 22, 2022 09:47
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