[vlc-commits] [Git][videolan/vlc][master] 2 commits: access: vdr: replace duplicated allocs and concats with memstream
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Oct 6 05:34:34 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
074bc0d0 by François Cartegnie at 2026-10-06T05:24:06+00:00
access: vdr: replace duplicated allocs and concats with memstream
refs #29806
Reported-by: Khoka Moni <khokamoni004 at gmail.com>
- - - - -
3cbd8b43 by François Cartegnie at 2026-10-06T05:24:06+00:00
access: vdr: check set seekpoint control
- - - - -
1 changed file:
- modules/access/vdr.c
Changes:
=====================================
modules/access/vdr.c
=====================================
@@ -63,6 +63,7 @@ See http://www.vdr-wiki.de/ and http://www.tvdr.de/ for more information.
#include <vlc_charset.h>
#include <vlc_dialog.h>
#include <vlc_configuration.h>
+#include <vlc_memstream.h>
/*****************************************************************************
* Module descriptor
@@ -322,6 +323,8 @@ static int Control( stream_t *p_access, int i_query, va_list args )
case STREAM_SET_SEEKPOINT:
i = va_arg( args, int );
+ if( i < 0 || !p_sys->p_marks || i >= p_sys->p_marks->i_seekpoint )
+ return VLC_EGENERIC;
return Seek( p_access, p_sys->offsets[i] );
case STREAM_GET_META:
@@ -657,7 +660,6 @@ static void ImportMeta( stream_t *p_access )
char *line = NULL;
size_t line_len;
- char *psz_title = NULL, *psz_smalltext = NULL, *psz_date = NULL;
while( ReadLine( &line, &line_len, infofile ) )
{
@@ -691,8 +693,6 @@ static void ImportMeta( stream_t *p_access )
/* TODO: locale */
strftime( str, sizeof(str), "%Y-%m-%d %H:%M", &tm );
vlc_meta_SetExtra( p_meta, "Date", str );
- free( psz_date );
- psz_date = strdup( str );
/* display in minutes */
i_length = ( i_length + 59 ) / 60;
@@ -703,15 +703,11 @@ static void ImportMeta( stream_t *p_access )
else if( tag == 'T' )
{
- free( psz_title );
- psz_title = strdup( text );
vlc_meta_SetExtra( p_meta, "Title", text );
}
else if( tag == 'S' )
{
- free( psz_smalltext );
- psz_smalltext = strdup( text );
vlc_meta_SetExtra( p_meta, "Info", text );
}
@@ -746,36 +742,31 @@ static void ImportMeta( stream_t *p_access )
}
/* create a meaningful title */
- int i_len = 10 +
- ( psz_title ? strlen( psz_title ) : 0 ) +
- ( psz_smalltext ? strlen( psz_smalltext ) : 0 ) +
- ( psz_date ? strlen( psz_date ) : 0 );
- char *psz_display = malloc( i_len );
-
- if( psz_display )
+ struct vlc_memstream memstream;
+ if( vlc_memstream_open( &memstream ) == 0 )
{
- *psz_display = '\0';
+ const char *psz_title = vlc_meta_GetExtra( p_meta, "Title" );
+ const char *psz_smalltext = vlc_meta_GetExtra( p_meta, "Info" );
+ const char *psz_date = vlc_meta_GetExtra( p_meta, "Date" );
+
if( psz_title )
- strcat( psz_display, psz_title );
- if( psz_title && psz_smalltext )
- strcat( psz_display, " - " );
+ {
+ vlc_memstream_puts( &memstream, psz_title );
+ if( psz_smalltext )
+ vlc_memstream_puts( &memstream, " - " );
+ }
if( psz_smalltext )
- strcat( psz_display, psz_smalltext );
+ vlc_memstream_puts( &memstream, psz_smalltext );
if( ( psz_title || psz_smalltext ) && psz_date )
+ vlc_memstream_printf( &memstream, " (%s)", psz_date );
+ if( vlc_memstream_close( &memstream ) == 0 )
{
- strcat( psz_display, " (" );
- strcat( psz_display, psz_date );
- strcat( psz_display, ")" );
+ if( memstream.length )
+ vlc_meta_SetTitle( p_meta, memstream.ptr );
+ free( memstream.ptr );
}
- if( *psz_display )
- vlc_meta_SetTitle( p_meta, psz_display );
}
- free( psz_display );
- free( psz_title );
- free( psz_smalltext );
- free( psz_date );
-
fclose( infofile );
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e358f3098c2f2b7621d1dc568de8b61ad786322...3cbd8b43a5a8760e8f1887c707b0373404ef31e1
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e358f3098c2f2b7621d1dc568de8b61ad786322...3cbd8b43a5a8760e8f1887c707b0373404ef31e1
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list