[vlc-commits] libvlc: media: remove flexible array member
Thomas Guillem
git at videolan.org
Tue May 24 11:40:39 CEST 2016
vlc | branch: master | Thomas Guillem <git at videolan.org> | Fri May 20 10:33:23 2016 +0200| [45bc33349134f308a1a9a5cc01995adc113ea96f] | committer: Thomas Guillem
libvlc: media: remove flexible array member
Because ISO C++ has no notation of flexible arrays and this a public header.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=45bc33349134f308a1a9a5cc01995adc113ea96f
---
include/vlc/libvlc_media.h | 2 +-
lib/media.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index 173c78a..bd8a9c4 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -286,9 +286,9 @@ typedef enum
*/
typedef struct
{
+ char * psz_uri;
libvlc_media_slave_type_t i_type;
unsigned int i_priority;
- char psz_uri[];
} libvlc_media_slave_t;
/**
diff --git a/lib/media.c b/lib/media.c
index c11f8f9..7d47a9e 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -1164,15 +1164,16 @@ unsigned int libvlc_media_slaves_get( libvlc_media_t *p_md,
input_item_slave_t *p_item_slave = p_input_item->pp_slaves[i];
assert( p_item_slave->i_priority >= SLAVE_PRIORITY_MATCH_NONE );
+ /* also allocate psz_uri buffer at the end of the struct */
libvlc_media_slave_t *p_slave = malloc( sizeof(*p_slave) +
strlen( p_item_slave->psz_uri )
+ 1 );
-
if( p_slave == NULL )
{
libvlc_media_slaves_release(pp_slaves, i);
return vlc_mutex_unlock( &p_input_item->lock ), 0;
}
+ p_slave->psz_uri = (char *) ((uint8_t *)p_slave) + sizeof(*p_slave);
strcpy( p_slave->psz_uri, p_item_slave->psz_uri );
switch( p_item_slave->i_type )
More information about the vlc-commits
mailing list