antirez / antirez/sds

realloc may return NULL

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

Description

Hi @antirez,
according to the `man page`

```
realloc() returns a pointer to the newly allocated memory, which is
suitably aligned for any kind of variable and may be different from
ptr, or NULL if the request fails. If size was equal to 0, either NULL
or a pointer suitable to be passed to free() is returned. If realloc()
fails the original block is left untouched; it is not freed or moved.
```

in `sds.c` at line 717:

```
vector = realloc(vector, ((*argc)+1)*sizeof(char*));
```

if `realloc()` fails to allocate the requested memory, at line 718 it may get `segfault`.

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.