changeset 92:82af243658bd src

fix memleaks in dvdnav_open
author mroi
date Thu, 05 Sep 2002 12:55:05 +0000
parents df9712507b30
children e74cba5129a6
files dvdnav.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Wed Sep 04 11:41:52 2002 +0000
+++ b/dvdnav.c	Thu Sep 05 12:55:05 2002 +0000
@@ -181,9 +181,6 @@
   /* Create a new structure */
   fprintf(MSG_OUT, "libdvdnav: Using dvdnav version (devel-ref:jcd1) from http://dvd.sf.net\n");
 
-  /* FIXME: We malloc() here, but if an error occurs inside dvdnav_open(),
-   * we return but never free() it.
-   */
   (*dest) = NULL;
   this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
   if(!this)
@@ -199,10 +196,15 @@
   this->vm = vm_new_vm();
   if(!this->vm) {
     printerr("Error initialising the DVD VM");
+    pthread_mutex_destroy(&this->vm_lock);
+    free(this);
     return S_ERR;
   }
   if(vm_reset(this->vm, path) == -1) {
     printerr("Error starting the VM / opening the DVD device");
+    pthread_mutex_destroy(&this->vm_lock);
+    vm_free_vm(this->vm);
+    free(this);
     return S_ERR;
   }
 
@@ -998,6 +1000,9 @@
 
 /*
  * $Log$
+ * Revision 1.35  2002/09/05 12:55:05  mroi
+ * fix memleaks in dvdnav_open
+ *
  * Revision 1.34  2002/09/03 00:41:48  jcdutton
  * Add a comment so I can tell which version of the CVS a user is using.
  * Also add a FIXME to remind me to fix the Chapter number display.