antirez / antirez/sds

memory leak in sdssplitlen() ?

オープン
#43 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C
スター
5.6k
フォーク
510
PR マージ指標
30日以内にマージされた PR はありません

説明

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`?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。