[vlc-commits] subtitle: remove hand-coded conversion

Rémi Denis-Courmont git at videolan.org
Sun Nov 12 14:25:44 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 12 13:41:42 2017 +0200| [7ce0983bdefce8fc334ba8dbb99c526540c289b1] | committer: Rémi Denis-Courmont

subtitle: remove hand-coded conversion

This fixes an invalid free on error.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ce0983bdefce8fc334ba8dbb99c526540c289b1
---

 modules/demux/subtitle.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index cfbe106d1f..b6599c8269 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -426,29 +426,11 @@ static int Open ( vlc_object_t *p_this )
     {
         if( i_peek > 16 )
         {
-            vlc_iconv_t handle = vlc_iconv_open( "UTF-8", psz_bom );
-            if( handle )
-            {
-                char *p_outbuf = malloc( i_peek );
-                if( p_outbuf )
-                {
-                    const char *p_inbuf = (const char *) p_peek;
-                    char *psz_converted = p_outbuf;
-                    const size_t i_outbuf_size = i_peek;
-                    size_t i_inbuf_remain = i_peek;
-                    size_t i_outbuf_remain = i_peek;
-                    if ( VLC_ICONV_ERR != vlc_iconv( handle,
-                                                     &p_inbuf, &i_inbuf_remain,
-                                                     &p_outbuf, &i_outbuf_remain ) )
-                    {
-                        p_probestream = vlc_stream_MemoryNew( p_demux, (uint8_t *) psz_converted,
-                                                            i_outbuf_size - i_outbuf_remain,
-                                                            false ); /* free p_outbuf on release */
-                    }
-                    else free( p_outbuf );
-                }
-                vlc_iconv_close( handle );
-            }
+            char *p_outbuf = FromCharset( psz_bom, p_peek, i_peek );
+            if( p_outbuf != NULL )
+                p_probestream = vlc_stream_MemoryNew( p_demux, (uint8_t *)p_outbuf,
+                                                      strlen( p_outbuf ),
+                                                      false ); /* free p_outbuf on release */
         }
     }
     else



More information about the vlc-commits mailing list