Browse Source

modules: optimize string minimum size checks

No need to go through all the chars when we can just check a minimum size with
strnlen().
pull/138/head
Steve Lhomme 4 years ago
parent
commit
fc6ade229c
  1. 2
      modules/access/dsm/access.c
  2. 2
      modules/codec/atsc_a65.c
  3. 2
      modules/codec/libass.c
  4. 2
      modules/demux/mjpeg.c
  5. 2
      modules/demux/mkv/mkv.cpp
  6. 2
      modules/stream_out/rtp.c

2
modules/access/dsm/access.c

@ -645,7 +645,7 @@ static bool get_path( stream_t *p_access )
backslash_path( p_sys->psz_fullpath );
/* Is path longer than just "/" ? */
if( strlen( p_sys->psz_fullpath ) > 1 )
if( strnlen( p_sys->psz_fullpath, 1+1 ) > 1 )
{
iter = p_sys->psz_fullpath;
while( *iter == '\\' ) iter++; /* Handle smb://Host/////Share/ */

2
modules/codec/atsc_a65.c

@ -72,7 +72,7 @@ atsc_a65_handle_t *atsc_a65_handle_New( const char *psz_lang )
atsc_a65_handle_t *p_handle = malloc( sizeof(*p_handle) );
if( p_handle )
{
if( psz_lang && strlen(psz_lang) > 2 )
if( psz_lang && strnlen(psz_lang, 2+1) > 2 )
p_handle->psz_lang = strdup( psz_lang );
else
p_handle->psz_lang = NULL;

2
modules/codec/libass.c

@ -180,7 +180,7 @@ static int Create( vlc_object_t *p_this )
if( !strcasecmp( p_attach->psz_mime, "application/x-truetype-font" ) )
found = true;
/* Then extension */
else if( !found && strlen( p_attach->psz_name ) > 4 )
else if( !found && strnlen( p_attach->psz_name, 4+1 ) > 4 )
{
char *ext = p_attach->psz_name + strlen( p_attach->psz_name ) - 4;

2
modules/demux/mjpeg.c

@ -507,7 +507,7 @@ static int MimeDemux( demux_t *p_demux )
/* Handle old and new style of separators */
if (!strncmp(p_sys->psz_separator, (char *)(p_sys->p_peek + i + 2),
strlen( p_sys->psz_separator ))
|| ((strlen(p_sys->psz_separator) > 4)
|| ((strnlen(p_sys->psz_separator, 4+1) > 4)
&& !strncmp(p_sys->psz_separator, "--", 2)
&& !strncmp(p_sys->psz_separator, (char *)(p_sys->p_peek + i),
strlen( p_sys->psz_separator))))

2
modules/demux/mkv/mkv.cpp

@ -192,7 +192,7 @@ static int OpenInternal( demux_t *p_demux, bool trust_cues )
const char *psz_file;
while ((psz_file = vlc_readdir(p_src_dir)) != NULL)
{
if (strlen(psz_file) > 4)
if (strnlen(psz_file, 4+1) > 4)
{
s_filename = s_path + DIR_SEP_CHAR + psz_file;

2
modules/stream_out/rtp.c

@ -766,7 +766,7 @@ char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url )
inclport = false;
/* Check against URL format rtsp://[<ipv6>]:<port>/<path> */
bool ipv6 = rtsp_url != NULL && strlen( rtsp_url ) > 7
bool ipv6 = rtsp_url != NULL && strnlen( rtsp_url, 7+1 ) > 7
&& rtsp_url[7] == '[';
/* Dummy destination address for RTSP */

Loading…
Cancel
Save