antirez / antirez/sds

memory leak in sdssplitlen() ?

Đang mở
#43 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
5.6k
Fork
510
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.