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
Mismatch of generic variable name using "NOT" statement #2
Comments
Hi Anis, thanks for using weggli and the detailed bug report. not_dangling_wrong() only fails because it finds 2 matches: free(data) and free(handle). |
Hey Felix, #[test]
fn not_dangling() {
let needle = "{free($handle); not: $handle= NULL;}";
let source = r"
int32_t random_func_name2(random_struct **handle_ptr)
{
random_struct_data *data = NULL;
random_struct *handle = NULL;
if ((handle_ptr != NULL) && (*handle_ptr != NULL)) {
handle = *handle_ptr;
data = (random_struct_data*)handle->_data;
if (data != NULL) {
if (data->name != NULL) {
//TODO
}
free(data); //this should not match
data = NULL ;
}
if (handle != NULL) {
free(handle); //this should match
}
*handle_ptr = NULL;
}
return 0;
}";
let matches = parse_and_match(needle, source);
assert_eq!(matches, 1);
} The expected match for this case is 1 instead of 2.
|
Hey Anis, thanks for the new test case. Nice catch :) |
Hey Felix, Thank you for the swift fix; |
Hello,
While trying to generate a pattern for matching dangling pointer bugs on a random code-base I run into an issue.
Explicitly writing the variable name ==> does result in a match.
Using a generic variable name ($data) ==> does not result in a match.
ie:
Needle:
{free($data); not: $data = NULL;}
- doesnt match ==> expected behavior : MATCHNeedle:
{free(data); not: data = NULL;}
- does match ==> expected behavior : MATCHTest file to reproduce the issue (only needle changed):
The text was updated successfully, but these errors were encountered: