From ef650d0398f10e7f14bf8c9da6390bc3d76df415 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 18 Dec 2009 17:32:16 +0000 Subject: [PATCH] (trunk libT) it certainly smells like we're using freed memory in the libcurl + libevent code in web.c... let's trash the structures right before free()ing them --- libtransmission/web.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libtransmission/web.c b/libtransmission/web.c index 7ec2b6fcb..c123a5e34 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -23,6 +23,8 @@ enum { + TR_MEMORY_TRASH = 0xCC, + DEFAULT_TIMER_MSEC = 1500 /* arbitrary */ }; @@ -57,6 +59,7 @@ web_free( tr_web * g ) { curl_multi_cleanup( g->multi ); evtimer_del( &g->timer_event ); + memset( g, TR_MEMORY_TRASH, sizeof( struct tr_web ) ); tr_free( g ); } @@ -81,6 +84,7 @@ task_free( struct tr_web_task * task ) evbuffer_free( task->response ); tr_free( task->range ); tr_free( task->url ); + memset( task, TR_MEMORY_TRASH, sizeof( struct tr_web_task ) ); tr_free( task ); } @@ -282,6 +286,7 @@ sock_cb( CURL * e UNUSED, curl_socket_t fd, int action, if( io_event != NULL ) { event_del( io_event ); + memset( io_event, TR_MEMORY_TRASH, sizeof( struct event ) ); tr_free( io_event ); curl_multi_assign( web->multi, fd, NULL ); /*fprintf( stderr, "-1 io_events to %d\n", --num_events );*/