From f8b9b57028acbf61afaf1ef2e18fe1bee92c3ff2 Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Wed, 21 Oct 2009 14:49:20 +0200 Subject: [PATCH] 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 --- torrentfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;