Index: src/control/vlm.c =================================================================== --- src/control/vlm.c (revision 20410) +++ src/control/vlm.c (working copy) @@ -61,6 +61,7 @@ } } free( psz_childprefix ); + psz_childprefix = NULL; return psz_response; } @@ -89,6 +90,7 @@ } } free( psz_message ); + psz_message = NULL; return(psz_response ); #endif return NULL; Index: src/misc/objects.c =================================================================== --- src/misc/objects.c (revision 20410) +++ src/misc/objects.c (working copy) @@ -392,7 +392,11 @@ free( p_this->p_vars ); vlc_mutex_destroy( &p_this->var_lock ); - if( p_this->psz_header ) free( p_this->psz_header ); + if( p_this->psz_header ) + { + free( p_this->psz_header ); + p_this->psz_header = NULL; + } if( p_this->i_object_type == VLC_OBJECT_GLOBAL ) { Index: src/input/vlm.c =================================================================== --- src/input/vlm.c (revision 20410) +++ src/input/vlm.c (working copy) @@ -147,9 +147,11 @@ vlm_MessageDelete(p_message); free(psz_buffer); + psz_buffer = NULL; } } free(psz_vlmconf); + psz_vlmconf = NULL; vlc_mutex_unlock( lockval.p_address ); @@ -606,6 +608,7 @@ *pp_status = vlm_MessageNew( "export", psz_export ); free( psz_export ); + psz_export=NULL; return VLC_SUCCESS; } @@ -625,6 +628,7 @@ } fwrite( psz_save, strlen( psz_save ), 1, f ); free( psz_save ); + psz_save = NULL; fclose( f ); *pp_status = vlm_MessageNew( "save", NULL ); @@ -675,13 +679,15 @@ if( Load( p_vlm, psz_buffer ) ) { free( psz_buffer ); + psz_buffer = NULL; *pp_status = vlm_MessageNew( "load", "Error while loading file" ); return VLC_EGENERIC; } free( psz_buffer ); - + psz_buffer = NULL; + *pp_status = vlm_MessageNew( "load", NULL ); return VLC_SUCCESS; } @@ -1087,15 +1093,22 @@ TAB_REMOVE( vlm->i_schedule, vlm->schedule, sched ); - if( vlm->i_schedule == 0 && vlm->schedule ) free( vlm->schedule ); + if( vlm->i_schedule == 0 && vlm->schedule ) + { + free( vlm->schedule ); + vlm->schedule = NULL; + } free( sched->psz_name ); + sched->psz_name = NULL; while( sched->i_command ) { char *psz_cmd = sched->command[0]; TAB_REMOVE( sched->i_command, sched->command, psz_cmd ); free( psz_cmd ); + psz_cmd = NULL; } free( sched ); + sched = NULL; } static vlm_schedule_sys_t *vlm_ScheduleSearch( vlm_t *vlm, const char *psz_name ) @@ -1327,6 +1340,7 @@ { va_end( args ); free( p_message ); + p_message = NULL; return NULL; } va_end( args ); @@ -1341,12 +1355,25 @@ void vlm_MessageDelete( vlm_message_t *p_message ) { - if( p_message->psz_name ) free( p_message->psz_name ); - if( p_message->psz_value ) free( p_message->psz_value ); - while( p_message->i_child-- ) - vlm_MessageDelete( p_message->child[p_message->i_child] ); - if( p_message->child ) free( p_message->child ); - free( p_message ); + if( p_message->psz_name ) + { + free( p_message->psz_name ); + p_message->psz_name = NULL; + } + if( p_message->psz_value ) + { + free( p_message->psz_value ); + p_message->psz_value = NULL; + } + while( p_message->i_child-- ) + vlm_MessageDelete( p_message->child[p_message->i_child] ); + if( p_message->child ) + { + free( p_message->child ); + p_message->child = NULL; + } + free( p_message ); + p_message = NULL; } /* Add a child */ @@ -1394,6 +1421,7 @@ vlm_MessageAdd( p_msg_sub, vlm_MessageNew( psz_tmp, p_cfg->ppsz_input[i] ) ); free( psz_tmp ); + psz_tmp = NULL; } vlm_MessageAdd( p_msg, @@ -1433,6 +1461,7 @@ var_Get ## type( p_instance->p_input, a ) ); \ vlm_MessageAdd( p_msg_instance, vlm_MessageNew( a, psz_tmp ) ); \ free( psz_tmp ); + psz_tmp = NULL; APPEND_INPUT_INFO( "position", "%f", Float ); APPEND_INPUT_INFO( "time", I64Fi, Time ); APPEND_INPUT_INFO( "length", I64Fi, Time ); @@ -1445,6 +1474,7 @@ asprintf( &psz_tmp, "%d", p_instance->i_index + 1 ); vlm_MessageAdd( p_msg_instance, vlm_MessageNew( "playlistindex", psz_tmp ) ); free( psz_tmp ); + psz_tmp = NULL; } return p_msg; } @@ -1500,6 +1530,7 @@ vlm_MessageAdd( msg_schedule, vlm_MessageNew( "date", psz_date ) ); free( psz_date ); + psz_date = NULL; } else { @@ -1572,6 +1603,7 @@ p_msg = vlm_MessageNew( "show", NULL ); p_msg_child = vlm_MessageAdd( p_msg, vlm_MessageNew( "media", psz_count ) ); free( psz_count ); + psz_count = NULL; for( i = 0; i < vlm->i_media; i++ ) vlm_MessageAdd( p_msg_child, vlm_ShowMedia( vlm, vlm->media[i] ) ); @@ -1647,7 +1679,9 @@ /* We must destroy the parent node "show" of show2 * and not the children */ free( show2->psz_name ); + show2->psz_name = NULL; free( show2 ); + show2 = NULL; return show1; } @@ -2071,11 +2105,16 @@ vlc_mutex_lock( &vlm->lock ); - /* destroy the inputs that wants to die, and launch the next input */ + /* destroy the inputs that want to die, and launch the next input */ for( i = 0; i < vlm->i_media; i++ ) { vlm_media_sys_t *p_media = vlm->media[i]; + if ( p_media->i_instance == 0 ) + { + vlc_mutex_unlock( &vlm->lock ); + return VLC_SUCCESS; + } for( j = 0; j < p_media->i_instance; ) { vlm_media_instance_sys_t *p_instance = p_media->instance[j]; @@ -2104,9 +2143,13 @@ } } - /* scheduling */ + vlc_mutex_unlock( &vlm->lock ); + + /* scheduling - Don't hold Lock */ i_time = vlm_Date(); + vlc_mutex_lock( &vlm->lock ); + for( i = 0; i < vlm->i_schedule; i++ ) { mtime_t i_real_date = vlm->schedule[i]->i_date; @@ -2156,6 +2199,7 @@ ppsz_scheduled_commands, psz_command ); free( psz_command ); + psz_command = NULL; } i_lastcheck = i_time; @@ -2284,7 +2328,9 @@ input_DestroyThreadExtended( p_input, NULL ); } free( psz_output ); + psz_output = NULL; free( psz_header ); + psz_header = NULL; if( p_cfg->vod.psz_mux ) { @@ -2415,6 +2461,7 @@ TAB_REMOVE( p_vlm->i_media, p_vlm->media, p_media ); free( p_media ); + p_media = NULL; /* Check if we need to unload the VOD server */ if( p_vlm->p_vod && p_vlm->i_vod <= 0 ) @@ -2517,8 +2564,12 @@ input_ItemClean( &p_instance->item ); if( p_instance->psz_name ) + { free( p_instance->psz_name ); + p_instance->psz_name = NULL; + } free( p_instance ); + p_instance = NULL; } @@ -2606,7 +2657,10 @@ /* Start new one */ p_instance->i_index = i_input_index; if( p_instance->item.psz_uri ) + { free( p_instance->item.psz_uri ); + p_instance->item.psz_uri = NULL; + } p_instance->item.psz_uri = strdup( p_media->cfg.ppsz_input[p_instance->i_index] ); asprintf( &psz_log, _("Media: %s"), p_media->cfg.psz_name ); @@ -2617,6 +2671,7 @@ vlm_MediaInstanceDelete( p_instance ); } free( psz_log ); + psz_log = NULL; return VLC_SUCCESS; } Index: src/input/input.c =================================================================== --- src/input/input.c (revision 20410) +++ src/input/input.c (working copy) @@ -288,7 +288,7 @@ } vlc_mutex_destroy( &p_input->p->lock_control ); - free( p_input->p ); + FREENULL( p_input->p ); vlc_object_destroy( p_input ); } Index: modules/misc/freetype.c =================================================================== --- modules/misc/freetype.c (revision 20410) +++ modules/misc/freetype.c (working copy) @@ -382,6 +382,7 @@ FT_Done_Face( p_sys->p_face ); FT_Done_FreeType( p_sys->p_library ); free( p_sys ); + p_sys = NULL; } /***************************************************************************** Index: include/vlc_input.h =================================================================== --- include/vlc_input.h (revision 20410) +++ include/vlc_input.h (working copy) @@ -135,12 +135,12 @@ { int i; - free( p_i->psz_name ); - free( p_i->psz_uri ); + FREENULL( p_i->psz_name ); + FREENULL( p_i->psz_uri ); if( p_i->p_stats ) { vlc_mutex_destroy( &p_i->p_stats->lock ); - free( p_i->p_stats ); + FREENULL( p_i->p_stats ); } if( p_i->p_meta ) @@ -148,15 +148,14 @@ for( i = 0; i < p_i->i_options; i++ ) { - if( p_i->ppsz_options[i] ) - free( p_i->ppsz_options[i] ); + FREENULL( p_i->ppsz_options[i] ); } TAB_CLEAN( p_i->i_options, p_i->ppsz_options ); for( i = 0; i < p_i->i_es; i++ ) { es_format_Clean( p_i->es[i] ); - free( p_i->es[i] ); + FREENULL( p_i->es[i] ); } TAB_CLEAN( p_i->i_es, p_i->es ); @@ -169,16 +168,14 @@ { struct info_t *p_info = p_category->pp_infos[j]; - if( p_info->psz_name ) - free( p_info->psz_name); - if( p_info->psz_value ) - free( p_info->psz_value ); - free( p_info ); + FREENULL( p_info->psz_name); + FREENULL( p_info->psz_value ); + FREENULL( p_info ); } TAB_CLEAN( p_category->i_infos, p_category->pp_infos ); - if( p_category->psz_name ) free( p_category->psz_name ); - free( p_category ); + FREENULL( p_category->psz_name ); + FREENULL( p_category ); } TAB_CLEAN( p_i->i_categories, p_i->pp_categories ); @@ -219,8 +216,8 @@ static inline void vlc_seekpoint_Delete( seekpoint_t *point ) { if( !point ) return; - if( point->psz_name ) free( point->psz_name ); - free( point ); + FREENULL( point->psz_name ); + FREENULL( point ); } static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src ) @@ -270,14 +267,14 @@ if( t == NULL ) return; - if( t->psz_name ) free( t->psz_name ); + FREENULL( t->psz_name ); for( i = 0; i < t->i_seekpoint; i++ ) { - if( t->seekpoint[i]->psz_name ) free( t->seekpoint[i]->psz_name ); - free( t->seekpoint[i] ); + FREENULL( t->seekpoint[i]->psz_name ); + FREENULL( t->seekpoint[i] ); } - if( t->seekpoint ) free( t->seekpoint ); - free( t ); + FREENULL( t->seekpoint ); + FREENULL( t ); } static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )