antirez / antirez/sds

memory leak in sdssplitlen() ?

Aperta
#43 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C
Stelle
5.6k
Fork
510
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

In `sdssplitlen()`, `slots` starts with a default of 5. Then
`tokens = malloc(sizeof(sds)*slots);`
or generally 40 bytes.

However, `if (len == 0) { *count = 0; return tokens;}`

How do we free the 40 bytes? `sdsfreesplitres()` will use a count of 0.

Am I wrong that this is technically a memory leak? Of course, this is a situation that will probably never come up, since who splits a string with 0 chars, but still, it looks incorrect.

Why do we allocate memory to `tokens` before the test for `len == 0`?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.