Index: tv.c =================================================================== --- tv.c (revision 21825) +++ tv.c (working copy) @@ -480,6 +482,7 @@ sh_audio_t *sh_audio = NULL; tvi_functions_t *funcs; + demuxer->priv=NULL; if(!(tvh=tv_begin())) return NULL; if (!tv_init(tvh)) return NULL; if (!open_tv(tvh)){ @@ -625,7 +628,9 @@ static void demux_close_tv(demuxer_t *demuxer) { tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv); + if (!tvh) return; tvh->functions->uninit(tvh->priv); + demuxer->priv=NULL; } /* ================== STREAM_TV ===================== */ @@ -668,7 +682,11 @@ int tv_uninit(tvi_handle_t *tvh) { - return(tvh->functions->uninit(tvh->priv)); + if(!tvh) return 1; + if (!tvh->priv) return 1; + int res=tvh->functions->uninit(tvh->priv); + if(res) tvh->priv=NULL; + return res; } /* utilities for mplayer (not mencoder!!) */