github / github/codeql

C: Question aboutDataFlow Analyse

Aperta
#10,534 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
question
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

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 :(

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.