fix segfault

running list_del() twice will result in SEGFAULT
- first from connection.c:free_client() -> destroy_torrent()
- second from child_exit() -> destroy_torrent()

move list_del() to real cleanup after child was killed
This commit is contained in:
Olaf Rempel 2009-10-21 14:49:20 +02:00
parent be762c9abd
commit f8b9b57028

View File

@ -77,9 +77,6 @@ struct torrent_file * find_create_torrent(const char *fullpath)
int destroy_torrent(struct torrent_file *torrent)
{
/* remove us from list */
list_del(&torrent->list);
/* check if we're still seeding, and deferr the destroy after sigchld */
if (torrent->child != NULL) {
torrent->destroy = 1;
@ -89,6 +86,9 @@ int destroy_torrent(struct torrent_file *torrent)
return 0;
}
/* remove us from list */
list_del(&torrent->list);
free(torrent->name);
free(torrent);
return 0;