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

Inner blocks #25

Closed
sduverger opened this issue Nov 24, 2021 · 2 comments
Closed

Inner blocks #25

sduverger opened this issue Nov 24, 2021 · 2 comments

Comments

@sduverger
Copy link

Hi @felixwilhelm,

One of my colleagues discovered the following issue. When you uncomment the inner function blocks, you will observe an abnormal increasing number of matches:

  • 1 bloc = 1 match
  • 2 blocs = 657 matches
  • 3 blocs = 3404 matches
  • 4 blocs = 10446 matches
% cat test.pat
{
  _* $p = _;
  free($p);
  _;
  free($p);
}
% cat test.c
void double_free_multiple_blocks()
{
    {
	char *s = malloc(10);
	free(s);
	for (int i = 0; i < 10; i++) {
	    // do stuff
	}
	free(s);
    }
    {
	char *s = malloc(10);
	free(s);
	for (int i = 0; i < 10; i++) {
	    // do stuff
	}
	free(s);
    }
    //{
    //	char *s = malloc(10);
    //	free(s);
    //	for (int i = 0; i < 10; i++) {
    //	    // do stuff
    //	}
    //	free(s);
    //}
    //{
    //	char *s = malloc(10);
    //	free(s);
    //	for (int i = 0; i < 10; i++) {
    //	    // do stuff
    //	}
    //	free(s);
    //}
}
% weggli "$(<test.pat)" test.c | grep test.c | wc -l
   657
@felixwilhelm
Copy link
Collaborator

Nice catch. Matching of _; was too lax.
Should be fixed now :)

@sduverger
Copy link
Author

Thanks for your active support ! 👍

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

No branches or pull requests

2 participants