C: Question aboutDataFlow Analyse
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
Hi, I learn how to write ql to do dataflow analyse, and then I want to detect memory leak like missing `free` after `malloc`. But I met a problem, I don't know how to solve this problem.
C demo:
```
char* gen_ptr(void)
{
char* a = malloc(1);
return a;
}
int main(void)
{
char* a;
a = gen_ptr();
a = gen_ptr();
free(a);
return 0;
}
```
In this code, `gen_ptr` is called twice, but only freed in the end, there is a memory leak because the first `a `is not freed.
I use dataflow analyse and want to detect `malloc` in the first `gen_ptr` doesn't have a free as sink. But I faild....because `malloc` in `gen_ptr `does have a sink in the second one!!!
I think for a long time but do not know how to solve this problem :(
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.