comparison stream/tv.c @ 21837:922c0072a2bf

Two crash issues fixed: 1. Freeing of unallocated memory when tv driver fails to initialize itself. 2. Call to tv driver's tv_uninit more than once.
author voroshil
date Mon, 08 Jan 2007 05:55:46 +0000
parents ac69ba536915
children 6cabac4d35b5
comparison
equal deleted inserted replaced
21836:7c5e893dff54 21837:922c0072a2bf
478 tvi_handle_t *tvh; 478 tvi_handle_t *tvh;
479 sh_video_t *sh_video; 479 sh_video_t *sh_video;
480 sh_audio_t *sh_audio = NULL; 480 sh_audio_t *sh_audio = NULL;
481 tvi_functions_t *funcs; 481 tvi_functions_t *funcs;
482 482
483 demuxer->priv=NULL;
483 if(!(tvh=tv_begin())) return NULL; 484 if(!(tvh=tv_begin())) return NULL;
484 if (!tv_init(tvh)) return NULL; 485 if (!tv_init(tvh)) return NULL;
485 if (!open_tv(tvh)){ 486 if (!open_tv(tvh)){
486 tv_uninit(tvh); 487 tv_uninit(tvh);
487 return NULL; 488 return NULL;
623 } 624 }
624 625
625 static void demux_close_tv(demuxer_t *demuxer) 626 static void demux_close_tv(demuxer_t *demuxer)
626 { 627 {
627 tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv); 628 tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);
629 if (!tvh) return;
628 tvh->functions->uninit(tvh->priv); 630 tvh->functions->uninit(tvh->priv);
631 demuxer->priv=NULL;
629 } 632 }
630 633
631 /* ================== STREAM_TV ===================== */ 634 /* ================== STREAM_TV ===================== */
632 tvi_handle_t *tvi_init_dummy(char *device); 635 tvi_handle_t *tvi_init_dummy(char *device);
633 tvi_handle_t *tvi_init_v4l(char *device, char *adevice); 636 tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
666 return(tvh->functions->init(tvh->priv)); 669 return(tvh->functions->init(tvh->priv));
667 } 670 }
668 671
669 int tv_uninit(tvi_handle_t *tvh) 672 int tv_uninit(tvi_handle_t *tvh)
670 { 673 {
671 return(tvh->functions->uninit(tvh->priv)); 674 int res;
675 if(!tvh) return 1;
676 if (!tvh->priv) return 1;
677 res=tvh->functions->uninit(tvh->priv);
678 if(res) tvh->priv=NULL;
679 return res;
672 } 680 }
673 681
674 /* utilities for mplayer (not mencoder!!) */ 682 /* utilities for mplayer (not mencoder!!) */
675 int tv_set_color_options(tvi_handle_t *tvh, int opt, int value) 683 int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
676 { 684 {