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 #11542: FP memleak when using memcpy() with pointer #6792

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ludviggunne
Copy link
Contributor

Work in progress.

Just wanted to check if I'm heading in the right direction and using the
internal API correctly.

Is there a way to check if a variable is a pointer to a pointer?

@ludviggunne
Copy link
Contributor Author

Perhaps adding Variable::getIndirectionLevel() would be useful? Shouldn't be too hard to implement.

@chrchr-github
Copy link
Collaborator

var->valueType()->pointer should be 2 in this case.

@ludviggunne
Copy link
Contributor Author

var->valueType()->pointer should be 2 in this case.

Good to know!

" memcpy(&old, &str, sizeof(char*));\n"
"}\n");
// TODO: make this fail
ASSERT_EQUALS("", errout_str());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running cppcheck on this code on the command line (without any additional options) produces an error,but nothing happens in the test function.

What could the reason for this be?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe std.cfg is not loaded in that test, so strdup() and memcpy() are not recognized. There should be other tests where we load the library.

Copy link
Contributor Author

@ludviggunne ludviggunne Sep 11, 2024

Choose a reason for hiding this comment

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

I'm just matching the token with "memcpy" though, is the library loading really required for that?

Edit: right, the strdup is crucial

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