fix: memory leak in magnet parsing (#1222)
* Fix memory leak in magnet parsing * Update libtransmission/magnet.c Co-authored-by: Charles Kerr <charles@charleskerr.com> * Lint Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
fa6df52d58
commit
a82e728ad5
|
@ -174,7 +174,7 @@ tr_magnet_info* tr_magnetParse(char const* uri)
|
|||
}
|
||||
}
|
||||
|
||||
if (vallen > 0 && keylen == 2 && memcmp(key, "dn", 2) == 0)
|
||||
if (displayName == NULL && vallen > 0 && keylen == 2 && memcmp(key, "dn", 2) == 0)
|
||||
{
|
||||
displayName = tr_http_unescape(val, vallen);
|
||||
}
|
||||
|
@ -212,6 +212,20 @@ tr_magnet_info* tr_magnetParse(char const* uri)
|
|||
info->webseeds = tr_memdup(ws, sizeof(char*) * wsCount);
|
||||
memcpy(info->hash, sha1, sizeof(uint8_t) * SHA_DIGEST_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < trCount; i++)
|
||||
{
|
||||
tr_free(tr[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < wsCount; i++)
|
||||
{
|
||||
tr_free(ws[i]);
|
||||
}
|
||||
|
||||
tr_free(displayName);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue