瀏覽代碼

Check for failure to allocate memory.

master
Richard Nyberg 18 年之前
父節點
當前提交
36a68e4b76
共有 1 個檔案被更改,包括 4 行新增2 行删除
  1. +4
    -2
      misc/metainfo.c

+ 4
- 2
misc/metainfo.c 查看文件

@@ -69,7 +69,6 @@ check_path(const char *path, size_t len)
int int
fill_fileinfo(const char *fdct, struct fileinfo *tfp) fill_fileinfo(const char *fdct, struct fileinfo *tfp)
{ {
//int err;
size_t npath, plen, len; size_t npath, plen, len;
const char *plst, *iter, *str; const char *plst, *iter, *str;


@@ -147,7 +146,10 @@ fill_metainfo(const char *bep, struct metainfo *tp, int mem_hashes)
BE_STR, 2, "info", "name")) BE_STR, 2, "info", "name"))
return EINVAL; return EINVAL;


tp->announce = benc_dget_str(bep, "announce", NULL);
if ((tp->announce = benc_dget_str(bep, "announce", NULL)) == NULL) {
err = ENOMEM;
goto out;
}
bep = benc_dget_dct(bep, "info"); bep = benc_dget_dct(bep, "info");
SHA1(bep, benc_length(bep), tp->info_hash); SHA1(bep, benc_length(bep), tp->info_hash);
tp->piece_length = benc_dget_int(bep, "piece length"); tp->piece_length = benc_dget_int(bep, "piece length");


Loading…
取消
儲存