antirez / antirez/sds

realloc may return NULL

オープン
#23 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。