[MPlayer-dev-eng] [PATCH] Avoid freeing of unallocated memory in tv.c

Vladimir Voroshilov voroshil at gmail.com
Tue Jan 2 10:31:42 CET 2007


Hi, All
I have found small bug in tv.c.
If tvi_init_* function return NULL (e.g. fails to initialize driver)
demuxer->priv  will not point to allocated memory, but demux_close_tv does not
check this case and MPLayer will crash.
Attached trivial patch fixes this.

-- 
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
Omsk State University
JID: voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
Index: tv.c
===================================================================
--- tv.c	(revision 21808)
+++ tv.c	(working copy)
@@ -480,6 +480,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 +626,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 ===================== */


More information about the MPlayer-dev-eng mailing list