C: Question aboutDataFlow Analyse
- Langage dominant
- CodeQL
- Étoiles
- 10.1k
- Forks
- 2.1k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 141
Description
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 :(
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.