]> git.sesse.net Git - vlc/blobdiff - modules/codec/subtitles/subsdec.c
Fix memleaks in stream output.
[vlc] / modules / codec / subtitles / subsdec.c
index 76114f06ef6e3d6ee747ca86a219f2aff0660cbd..f6abcd9f3bc3002b7985deae2e2c04190675bffd 100644 (file)
@@ -49,7 +49,8 @@ static char           *CreateHtmlSubtitle ( char * );
 /*****************************************************************************
  * Module descriptor.
  *****************************************************************************/
-static const char *ppsz_encodings[] = { DEFAULT_NAME, "ASCII", "UTF-8", "",
+static const char *const ppsz_encodings[] = {
+    DEFAULT_NAME, "ASCII", "UTF-8", "",
     "ISO-8859-1", "CP1252", "MacRoman", "MacIceland","ISO-8859-15", "",
     "ISO-8859-2", "CP1250", "MacCentralEurope", "MacCroatian", "MacRomania", "",
     "ISO-8859-5", "CP1251", "MacCyrillic", "MacUkraine", "KOI8-R", "KOI8-U", "KOI8-RU", "",
@@ -96,8 +97,9 @@ The following known charsets are used:
 254 = PC 437
 */
 
-static int  pi_justification[] = { 0, 1, 2 };
-static const char *ppsz_justification_text[] = {N_("Center"),N_("Left"),N_("Right")};
+static const int  pi_justification[] = { 0, 1, 2 };
+static const char *const ppsz_justification_text[] = {
+    N_("Center"),N_("Left"),N_("Right")};
 
 #define ENCODING_TEXT N_("Subtitles text encoding")
 #define ENCODING_LONGTEXT N_("Set the encoding used in text subtitles")
@@ -158,10 +160,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     p_dec->p_sys = p_sys = malloc( sizeof( *p_sys ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     /* init of p_sys */
     memset( p_sys, 0, sizeof( *p_sys ) );
@@ -253,13 +252,19 @@ static int OpenDecoder( vlc_object_t *p_this )
  ****************************************************************************/
 static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 {
-    subpicture_t *p_spu = NULL;
+    subpicture_t *p_spu;
+    block_t *p_block;
+
+    if( !pp_block || *pp_block == NULL )
+        return NULL;
 
-    if( !pp_block || *pp_block == NULL ) return NULL;
+    p_block = *pp_block;
+    if( p_block->i_rate != 0 )
+        p_block->i_length = p_block->i_length * p_block->i_rate / INPUT_RATE_DEFAULT;
 
-    p_spu = ParseText( p_dec, *pp_block );
+    p_spu = ParseText( p_dec, p_block );
 
-    block_Release( *pp_block );
+    block_Release( p_block );
     *pp_block = NULL;
 
     return p_spu;
@@ -299,7 +304,7 @@ static void CloseDecoder( vlc_object_t *p_this )
                 continue;
 
             if( p_sys->pp_images[i]->p_pic )
-                p_sys->pp_images[i]->p_pic->pf_release( p_sys->pp_images[i]->p_pic );
+                picture_Release( p_sys->pp_images[i]->p_pic );
             free( p_sys->pp_images[i]->psz_filename );
 
             free( p_sys->pp_images[i] );