changeset 36555:46a0b7b3db4c

dvdnav: fix memory leaks in error paths.
author reimar
date Sun, 19 Jan 2014 22:24:46 +0000
parents d75b3dce7851
children 0803f123d737
files stream/stream_dvdnav.c
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_dvdnav.c	Sun Jan 19 22:24:45 2014 +0000
+++ b/stream/stream_dvdnav.c	Sun Jan 19 22:24:46 2014 +0000
@@ -107,18 +107,14 @@
 
   dvd_set_speed(priv->filename, dvd_speed);
 
-  if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK)
+  if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK || !priv->dvdnav)
   {
+    dvd_set_speed(priv->filename, -1);
     free(priv->filename);
     free(priv);
     return NULL;
   }
 
-  if (!priv->dvdnav) {
-    free(priv);
-    return NULL;
-  }
-
   if(1)	//from vlc: if not used dvdnav from cvs will fail
   {
     int len, event;
@@ -622,6 +618,7 @@
     priv->title = p->track;
     if(dvdnav_title_play(priv->dvdnav, p->track) != DVDNAV_STATUS_OK) {
       mp_msg(MSGT_OPEN,MSGL_FATAL,"dvdnav_stream, couldn't select title %d, error '%s'\n", p->track, dvdnav_err_to_string(priv->dvdnav));
+      stream_dvdnav_close(stream);
       return STREAM_UNSUPPORTED;
     }
     mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DVD_CURRENT_TITLE=%d\n", p->track);