Commit 7e908634 authored by Clément Stenac's avatar Clément Stenac

fix a bunch of memory leaks

parent 3bf76033
...@@ -211,11 +211,14 @@ struct intf_sys_t ...@@ -211,11 +211,14 @@ struct intf_sys_t
static int InitSocket( intf_thread_t *p_intf, char *psz_address, int i_port ); static int InitSocket( intf_thread_t *p_intf, char *psz_address, int i_port );
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
static int Decompress( unsigned char *psz_src, unsigned char **_dst, int i_len ); static int Decompress( unsigned char *psz_src, unsigned char **_dst, int i_len );
static void FreeSDP( sdp_t *p_sdp );
#endif #endif
/* Detect multicast addresses */ /* Detect multicast addresses */
static int ismult( char * ); static int ismult( char * );
#define FREE( p ) \
if( p ) { free( p ); (p) = NULL; }
/***************************************************************************** /*****************************************************************************
* Open: initialize and create stuff * Open: initialize and create stuff
*****************************************************************************/ *****************************************************************************/
...@@ -236,6 +239,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -236,6 +239,9 @@ static int Open( vlc_object_t *p_this )
p_sys->pi_fd = NULL; p_sys->pi_fd = NULL;
p_sys->i_fd = 0; p_sys->i_fd = 0;
/* FIXME */
p_sys->b_strict = VLC_FALSE;
if( config_GetInt( p_intf, "sap-use-cache" ) ) if( config_GetInt( p_intf, "sap-use-cache" ) )
{ {
CacheLoad( p_intf ); CacheLoad( p_intf );
...@@ -429,6 +435,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -429,6 +435,8 @@ static void Run( intf_thread_t *p_intf )
/* Parse the packet */ /* Parse the packet */
ParseSAP( p_intf, p_buffer, i_read ); ParseSAP( p_intf, p_buffer, i_read );
free( p_buffer );
} }
} }
...@@ -495,6 +503,9 @@ static int Demux( demux_t *p_demux ) ...@@ -495,6 +503,9 @@ static int Demux( demux_t *p_demux )
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
FreeSDP( p_sdp );
free( psz_sdp );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -641,10 +652,11 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read ) ...@@ -641,10 +652,11 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
else else
{ {
p_intf->p_sys->pp_announces[i]->i_last = mdate(); p_intf->p_sys->pp_announces[i]->i_last = mdate();
} FreeSDP( p_sdp );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
} }
}
/* Add item */ /* Add item */
if( p_sdp->i_media > 1 ) if( p_sdp->i_media > 1 )
{ {
...@@ -696,7 +708,8 @@ sap_announce_t *CreateAnnounce( intf_thread_t *p_intf, uint16_t i_hash, ...@@ -696,7 +708,8 @@ sap_announce_t *CreateAnnounce( intf_thread_t *p_intf, uint16_t i_hash,
if( !p_playlist ) if( !p_playlist )
{ {
msg_Err( p_intf, "playlist not found" ); msg_Err( p_intf, "playlist not found" );
/* FIXME : Free */ FREE( psz_value );
free( p_sap );
return NULL; return NULL;
} }
...@@ -893,6 +906,8 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp ) ...@@ -893,6 +906,8 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp )
{ {
asprintf( &p_sdp->psz_uri, "%s://%s:%i", psz_proto, psz_uri, i_port ); asprintf( &p_sdp->psz_uri, "%s://%s:%i", psz_proto, psz_uri, i_port );
} }
FREE( psz_uri );
FREE( psz_proto );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1026,8 +1041,6 @@ static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp ) ...@@ -1026,8 +1041,6 @@ static sdp_t * ParseSDP( vlc_object_t *p_obj, char* psz_sdp )
return p_sdp; return p_sdp;
} }
#define FREE( p ) \
if( p ) { free( p ); (p) = NULL; }
/*********************************************************************** /***********************************************************************
* ismult: returns true if we have a multicast address * ismult: returns true if we have a multicast address
...@@ -1129,6 +1142,22 @@ static int Decompress( unsigned char *psz_src, unsigned char **_dst, int i_len ) ...@@ -1129,6 +1142,22 @@ static int Decompress( unsigned char *psz_src, unsigned char **_dst, int i_len )
} }
#endif #endif
static void FreeSDP( sdp_t *p_sdp )
{
int i;
FREE( p_sdp->psz_sdp );
FREE( p_sdp->psz_sessionname );
FREE( p_sdp->psz_connection );
FREE( p_sdp->psz_media );
FREE( p_sdp->psz_uri );
for( i= 0 ; i< p_sdp->i_attributes; i++ )
{
FREE( p_sdp->pp_attributes[i] );
}
free( p_sdp );
}
static int RemoveAnnounce( intf_thread_t *p_intf, sap_announce_t *p_announce ) static int RemoveAnnounce( intf_thread_t *p_intf, sap_announce_t *p_announce )
{ {
msg_Err( p_intf, "remove not implemented"); msg_Err( p_intf, "remove not implemented");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment