antirez / antirez/sds

realloc may return NULL

未关闭
#23 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C
星标
5.6k
派生
510
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。