Commit c80f00f9 authored by Gildas Bazin's avatar Gildas Bazin

* modules/control/http.c: fixed a whole bunch of mem leaks.
parent f083827e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * Copyright (C) 2001-2004 VideoLAN
* $Id: http.c,v 1.44 2004/01/17 12:28:57 gbazin Exp $ * $Id: http.c,v 1.45 2004/01/17 13:25:21 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -297,10 +297,12 @@ static int Activate( vlc_object_t *p_this ) ...@@ -297,10 +297,12 @@ static int Activate( vlc_object_t *p_this )
goto failed; goto failed;
} }
p_intf->pf_run = Run; p_intf->pf_run = Run;
free( psz_src );
return VLC_SUCCESS; return VLC_SUCCESS;
failed: failed:
if( psz_src ) free( psz_src );
free( p_sys->pp_files ); free( p_sys->pp_files );
p_sys->p_httpd->pf_unregister_host( p_sys->p_httpd, p_sys->p_httpd->pf_unregister_host( p_sys->p_httpd,
p_sys->p_httpd_host ); p_sys->p_httpd_host );
...@@ -585,6 +587,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root, ...@@ -585,6 +587,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
if( !f ) if( !f )
{ {
msg_Err( p_intf, "Out of memory" ); msg_Err( p_intf, "Out of memory" );
closedir( p_dir );
return( VLC_ENOMEM ); return( VLC_ENOMEM );
} }
f->p_intf = p_intf; f->p_intf = p_intf;
...@@ -595,6 +598,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root, ...@@ -595,6 +598,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
if( !f->name || !f->mime ) if( !f->name || !f->mime )
{ {
msg_Err( p_intf , "Unable to parse directory" ); msg_Err( p_intf , "Unable to parse directory" );
closedir( p_dir );
return( VLC_ENOMEM ); return( VLC_ENOMEM );
} }
msg_Dbg( p_intf, "file=%s (url=%s mime=%s)", msg_Dbg( p_intf, "file=%s (url=%s mime=%s)",
...@@ -622,6 +626,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root, ...@@ -622,6 +626,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
if( !f ) if( !f )
{ {
msg_Err( p_intf, "Out of memory" ); msg_Err( p_intf, "Out of memory" );
closedir( p_dir );
return( VLC_ENOMEM ); return( VLC_ENOMEM );
} }
f->p_intf = p_intf; f->p_intf = p_intf;
...@@ -659,6 +664,9 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root, ...@@ -659,6 +664,9 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
{ {
free( password ); free( password );
} }
closedir( p_dir );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1966,6 +1974,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1966,6 +1974,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
case MVLC_STRING: case MVLC_STRING:
psz = config_GetPsz( p_intf, m->param1 ); psz = config_GetPsz( p_intf, m->param1 );
sprintf( value, "%s", psz ? psz : "" ); sprintf( value, "%s", psz ? psz : "" );
if( psz ) free( psz );
break; break;
default: default:
sprintf( value, "invalid type(%s) in set", m->param2 ); sprintf( value, "invalid type(%s) in set", m->param2 );
...@@ -2037,6 +2046,8 @@ static uint8_t *MacroSearch( uint8_t *src, uint8_t *end, int i_mvlc, vlc_bool_t ...@@ -2037,6 +2046,8 @@ static uint8_t *MacroSearch( uint8_t *src, uint8_t *end, int i_mvlc, vlc_bool_t
break; break;
} }
MacroClean( &m );
if( ( i_mvlc == MVLC_END && i_level == -1 ) || if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) ) ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
{ {
...@@ -2910,13 +2921,18 @@ playlist_item_t * parse_MRL( char *psz ) ...@@ -2910,13 +2921,18 @@ playlist_item_t * parse_MRL( char *psz )
if( s_temp == NULL ) if( s_temp == NULL )
{ {
i_error = 1; i_error = 1;
} else }
else
{ {
i_options++; i_options++;
ppsz_options = (char **)realloc( ppsz_options , i_options * sizeof(char *) ); ppsz_options = realloc( ppsz_options , i_options *
ppsz_options[ i_options - 1 ] = (char *)malloc( (s_temp - s_mrl + 1) * sizeof( char ) ); sizeof(char *) );
ppsz_options[ i_options - 1 ] =
malloc( (s_temp - s_mrl + 1) * sizeof(char) );
strncpy( ppsz_options[ i_options - 1 ] , s_mrl ,
s_temp - s_mrl );
strncpy( ppsz_options[ i_options - 1 ] , s_mrl , s_temp - s_mrl );
/* don't forget to finish the string with a '\0' */ /* don't forget to finish the string with a '\0' */
(ppsz_options[ i_options - 1 ])[ s_temp - s_mrl ] = '\0'; (ppsz_options[ i_options - 1 ])[ s_temp - s_mrl ] = '\0';
...@@ -2935,13 +2951,8 @@ playlist_item_t * parse_MRL( char *psz ) ...@@ -2935,13 +2951,8 @@ playlist_item_t * parse_MRL( char *psz )
if( i_error != 0 ) if( i_error != 0 )
{ {
free( mrl ); free( mrl );
for( i = 0 ; i < i_options ; i++ ) }
{ else
free( ppsz_options[i] );
}
free( ppsz_options );
return NULL;
} else
{ {
/* now create an item */ /* now create an item */
p_item = malloc( sizeof( playlist_item_t ) ); p_item = malloc( sizeof( playlist_item_t ) );
...@@ -2956,7 +2967,14 @@ playlist_item_t * parse_MRL( char *psz ) ...@@ -2956,7 +2967,14 @@ playlist_item_t * parse_MRL( char *psz )
{ {
playlist_AddItemOption( p_item, ppsz_options[i] ); playlist_AddItemOption( p_item, ppsz_options[i] );
} }
}
return p_item; for( i = 0 ; i < i_options ; i++ )
{
free( ppsz_options[i] );
} }
free( ppsz_options );
if( i_error != 0 ) return NULL;
else return p_item;
} }
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