C: Question aboutDataFlow Analyse
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.1k
- Forks
- 2.1k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 141
Descripción
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 :(
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.