[libdvdcss-devel] [PATCH 36/47] libdvdcss: Refactor error handling in dvdcss_open()

Diego Biurrun diego at biurrun.de
Wed Oct 29 21:33:36 CET 2014


---
 src/libdvdcss.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index aeba15c..44303a8 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -226,9 +226,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
         {
             print_error( dvdcss, "unknown decrypt method, please choose "
                                  "from 'title', 'key' or 'disc'" );
-            free( dvdcss->psz_device );
-            free( dvdcss );
-            return NULL;
+            goto error;
         }
     }
 
@@ -324,9 +322,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
     i_ret = dvdcss_open_device( dvdcss );
     if( i_ret < 0 )
     {
-        free( dvdcss->psz_device );
-        free( dvdcss );
-        return NULL;
+        goto error;
     }
 
     dvdcss->b_scrambled = 1; /* Assume the worst */
@@ -533,6 +529,11 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
     dvdcss->pf_seek( dvdcss, 0 );
 
     return dvdcss;
+
+error:
+    free( dvdcss->psz_device );
+    free( dvdcss );
+    return NULL;
 }
 
 /**
-- 
1.9.1



More information about the libdvdcss-devel mailing list