Skip to content
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

Fix #4778: FP: Uninitialized variable #6493

Merged
merged 2 commits into from
Jun 8, 2024

Conversation

olabetskyi
Copy link
Collaborator

No description provided.

@@ -1653,6 +1653,8 @@ void CheckUninitVar::valueFlowUninit()
if (!v->subexpressions.empty() && usage == ExprUsage::PassedByReference)
continue;
if (usage != ExprUsage::Used) {
if (tok->isUnaryOp("&") && !tok->astParent())
Copy link
Contributor

Choose a reason for hiding this comment

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

This check should probably be added to the getExprUsage function so it returns ExprUsage::NotUsed.

@chrchr-github chrchr-github merged commit 3e54980 into danmar:main Jun 8, 2024
63 checks passed
@mptre
Copy link
Contributor

mptre commented Jun 9, 2024

This change seem to have introduced a regression.

$ cat fp.c
void
fp(const char *str)
{
        const char *s = str;
        char *end;
        unsigned long val = 0;

        s = end;

        if (1) {
                val = strtoul(&s[1], &end, 10);
                if (val > INT_MAX)
                        return;
        }
}
$ cppcheck --enable=all fp.c
fp.c:11:9: error: Bad indirect value: 3 [internalError]
  val = strtoul(&s[1], &end, 10);
        ^

@chrchr-github
Copy link
Collaborator

This change seem to have introduced a regression.

Probably related to dc385f3

@danmar
Copy link
Owner

danmar commented Jun 9, 2024

@olabetskyi hmm which FP ticket did this solve? It wasn't 4478.

@olabetskyi
Copy link
Collaborator Author

@danmar danmar changed the title Fix #4478: FP: Uninitialized variable Fix #4778: FP: Uninitialized variable Jun 9, 2024
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.

5 participants