[libdvdcss-devel] libdvdcss: Refactor error handling in dvdcss_open()

[email protected] (Diego Biurrun)
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
libdvdcss | branch: master | Diego Biurrun <[email protected]> | Sat Oct 25 03:12:22 2014 +0200| [001afc48ac34b343c4b7fee858856bf3df540cdf] | committer: Diego Biurrun

libdvdcss: Refactor error handling in dvdcss_open()

> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=001afc48ac34b343c4b7fee858856bf3df540cdf
---

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

diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index a602050..b03dbfd 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -217,9 +217,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 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;
         }
     }
 
@@ -315,9 +313,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 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 */
@@ -524,6 +520,11 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
     dvdcss->pf_seek( dvdcss, 0 );
 
     return dvdcss;
+
+error:
+    free( dvdcss->psz_device );
+    free( dvdcss );
+    return NULL;
 }
 
 /**

_______________________________________________
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.