diff --git a/torrentfile.c b/torrentfile.c index ca61d8e..ad3e775 100644 --- a/torrentfile.c +++ b/torrentfile.c @@ -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;