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

Diego Biurrun <[email protected]>
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
---
 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

_______________________________________________
libdvdcss-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvdcss-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.