antirez / antirez/sds

realloc may return NULL

Offen
#23 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C
Sterne
5.6k
Forks
510
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.