antirez / antirez/sds

Memleak in sds.c:40

Open
#87 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
5.6k
Forks
510
PR merge metrics
No merged PRs in 30d

Description

There's a possible memleak and NULL ptr usage in sds.c:40 in `sdssplitargs`:

```c
vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
vector[*argc] = current;
```

Realloc here might return NULL and thus NULLify `vector` while losing the reference to original object. I believe something like the following should be done:
```c
char** new_vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
if (new_vector == NULL) goto err;
vector = new_vector;
vector[*argc] = current;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.