antirez / antirez/sds

realloc may return NULL

Abierto
#23 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C
Estrellas
5.6k
Forks
510
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.