changeset 20133:6d6c0840113f

Free track encodings on error or demuxer close
author reimar
date Mon, 09 Oct 2006 18:28:58 +0000
parents a8aa764559fa
children 42ce2edca8b7
files libmpdemux/demux_mkv.c
diffstat 1 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Mon Oct 09 18:22:57 2006 +0000
+++ b/libmpdemux/demux_mkv.c	Mon Oct 09 18:28:58 2006 +0000
@@ -704,6 +704,19 @@
   return 0;
 }
 
+/**
+ * \brief free array of kv_content_encoding_t
+ * \param encodings pointer to array
+ * \param numencodings number of encodings in array
+ */
+static void
+demux_mkv_free_encodings(mkv_content_encoding_t *encodings, int numencodings)
+{
+  while (numencodings-- > 0)
+    free(encodings[numencodings].comp_settings);
+  free(encodings);
+}
+
 static int
 demux_mkv_read_trackencodings (demuxer_t *demuxer, mkv_track_t *track)
 {
@@ -742,21 +755,21 @@
                   case MATROSKA_ID_CONTENTENCODINGORDER:
                     num = ebml_read_uint (s, &l);
                     if (num == EBML_UINT_INVALID)
-                      return 0;
+                      goto err_out;
                     e.order = num;
                     break;
 
                   case MATROSKA_ID_CONTENTENCODINGSCOPE:
                     num = ebml_read_uint (s, &l);
                     if (num == EBML_UINT_INVALID)
-                      return 0;
+                      goto err_out;
                     e.scope = num;
                     break;
 
                   case MATROSKA_ID_CONTENTENCODINGTYPE:
                     num = ebml_read_uint (s, &l);
                     if (num == EBML_UINT_INVALID)
-                      return 0;
+                      goto err_out;
                     e.type = num;
                     break;
 
@@ -777,7 +790,7 @@
                             case MATROSKA_ID_CONTENTCOMPALGO:
                               num = ebml_read_uint (s, &l);
                               if (num == EBML_UINT_INVALID)
-                                return 0;
+                                goto err_out;
                               e.comp_algo = num;
                               break;
 
@@ -859,6 +872,10 @@
   track->encodings = ce;
   track->num_encodings = n;
   return len;
+
+err_out:
+  demux_mkv_free_encodings(ce, n);
+  return 0;
 }
 
 static int
@@ -2702,6 +2719,8 @@
               if (mkv_d->tracks[i]->sh_sub.ass_track)
                 ass_free_track (mkv_d->tracks[i]->sh_sub.ass_track);
 #endif
+              demux_mkv_free_encodings(mkv_d->tracks[i]->encodings,
+                                       mkv_d->tracks[i]->num_encodings);
             }
           for (i=0; i < SUB_MAX_TEXT; i++)
             if (mkv_d->subs.text[i])