From a2c276959052b592fb37eeed0968ffeac02f0014 Mon Sep 17 00:00:00 2001 From: Steve Lhomme <robux4@ycbcr.xyz> Date: Fri, 28 Feb 2025 13:18:26 +0100 Subject: [PATCH] demux: subtitle: check the FORMAT= value is a number in mpsub We don't need vlc_strtof_c() since we already have the float value. We also don't need to check what is after the number (a comment for example). As long as it's a number it should be FPS. Anything else other than "FORMAT=TIME" is bogus. So we don't need to get the remaining part of the string. --- modules/demux/subtitle.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index d113df5d5c7..bb58034bef0 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -1761,22 +1761,14 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props, } else { - char *psz_temp = malloc( strlen(psz_format) + 1 ); - if( !psz_temp ) + float f_fps; + if( sscanf( psz_format, "%f", &f_fps ) == 1 ) { - return VLC_ENOMEM; - } - - if( sscanf( psz_format, "%[^\r\n]", psz_temp ) ) - { - float f_fps = vlc_strtof_c( psz_temp, NULL ); - if( f_fps > 0.f && var_GetFloat( p_obj, "sub-original-fps" ) <= 0.f ) var_SetFloat( p_obj, "sub-original-fps", f_fps ); p_props->mpsub.i_factor = 1; } - free( psz_temp ); } } } -- GitLab