[vlc-commits] demux: subtitle: fix leak
Francois Cartegnie
git at videolan.org
Tue Jan 24 15:42:04 CET 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan 24 14:20:32 2017 +0100| [49d373ff581dd14ccc5658ed130de2cd414cd54e] | committer: Francois Cartegnie
demux: subtitle: fix leak
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49d373ff581dd14ccc5658ed130de2cd414cd54e
---
modules/demux/subtitle.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 3bcca91..acb46a6 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -519,18 +519,19 @@ static int Open ( vlc_object_t *p_this )
TextLoad( &p_sys->txt, p_demux->s );
/* Parse it */
- for( size_t i_max = 0;; )
+ for( size_t i_max = 0; i_max < SIZE_MAX - 500 * sizeof(subtitle_t); )
{
if( p_sys->subtitles.i_count >= i_max )
{
i_max += 500;
- if( !( p_sys->subtitles.p_array = realloc_or_free( p_sys->subtitles.p_array,
- sizeof(subtitle_t) * i_max ) ) )
+ subtitle_t *p_realloc = realloc( p_sys->subtitles.p_array, sizeof(subtitle_t) * i_max );
+ if( p_realloc == NULL )
{
TextUnload( &p_sys->txt );
- free( p_sys );
+ Close( p_this );
return VLC_ENOMEM;
}
+ p_sys->subtitles.p_array = p_realloc;
}
if( pf_read( p_demux, &p_sys->subtitles.p_array[p_sys->subtitles.i_count],
More information about the vlc-commits
mailing list