shithub: libdvdcss

Download patch

ref: 76a8dee9721ac948f4e008f80ffe09c43b899586
parent: 7de33d1293d14c57579f162670586292d90995fa
author: Diego Biurrun <diego@biurrun.de>
date: Wed Nov 12 18:53:41 EST 2014

Properly check for and return errors from close().

Also fix a memory leak on close() failure.

--- a/src/device.c
+++ b/src/device.c
@@ -426,13 +426,16 @@
     free( dvdcss->p_readv_buffer );
     dvdcss->p_readv_buffer   = NULL;
     dvdcss->i_readv_buf_size = 0;
-
-    return 0;
 #else
-    close( dvdcss->i_fd );
+    int i_ret = close( dvdcss->i_fd );
+    if( i_ret < 0 )
+    {
+        print_error( dvdcss, "Failed to close fd, data loss possible." );
+        return i_ret;
+    }
+#endif
 
     return 0;
-#endif
 }
 
 /* Following functions are local */
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -781,15 +781,10 @@
 
     i_ret = dvdcss_close_device( dvdcss );
 
-    if( i_ret < 0 )
-    {
-        return i_ret;
-    }
-
     free( dvdcss->psz_device );
     free( dvdcss );
 
-    return 0;
+    return i_ret;
 }
 
 /**