[libdvdnav-devel] dvdinput_close(): fix leak in error path

Petri Hintukainen git at videolan.org
Thu Sep 24 13:33:48 CEST 2015


libdvdread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Thu Sep 24 14:02:23 2015 +0300| [54c4660e7592e6f8e30d205b117dfc9b1e3997be] | committer: Petri Hintukainen

dvdinput_close(): fix leak in error path

Memory should be freed even if DVDCSS_close() or close() returns an error.
Error return value is only for diagnostics; those functions can't be called again.
=> dvdinput_close() can't be called again.

> http://git.videolan.org/gitweb.cgi/libdvdread.git/?a=commit;h=54c4660e7592e6f8e30d205b117dfc9b1e3997be
---

 src/dvd_input.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/dvd_input.c b/src/dvd_input.c
index c3d25cc..4ec60a1 100644
--- a/src/dvd_input.c
+++ b/src/dvd_input.c
@@ -158,12 +158,9 @@ static int css_close(dvd_input_t dev)
 
   ret = DVDcss_close(dev->dvdcss);
 
-  if(ret < 0)
-    return ret;
-
   free(dev);
 
-  return 0;
+  return ret;
 }
 
 /**
@@ -278,12 +275,9 @@ static int file_close(dvd_input_t dev)
 
   ret = close(dev->fd);
 
-  if(ret < 0)
-    return ret;
-
   free(dev);
 
-  return 0;
+  return ret;
 }
 
 



More information about the libdvdnav-devel mailing list