[vlc-commits] [Git][videolan/vlc][master] 5 commits: demux: caf: free the previous extra data before allocating a new buffer
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat May 23 06:44:49 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6c93300e by Steve Lhomme at 2026-05-23T06:30:49+00:00
demux: caf: free the previous extra data before allocating a new buffer
As we read chunks and keep the information from the last one, the
format may have already been allocated before.
Fixes #29670
- - - - -
bd20ea96 by Steve Lhomme at 2026-05-23T06:30:49+00:00
demux: caf: consider the extra data allocation failed when the size is not 0
Ref. #29670
- - - - -
cdd31f62 by Steve Lhomme at 2026-05-23T06:30:49+00:00
demux: caf: don't allocate a size of 0
- - - - -
b48701c1 by Steve Lhomme at 2026-05-23T06:30:49+00:00
demux: caf: avoid memcpy() with 0 size
- - - - -
03e0366f by Steve Lhomme at 2026-05-23T06:30:49+00:00
demux: caf: reduce scope of local variable
- - - - -
1 changed file:
- modules/demux/caf.c
Changes:
=====================================
modules/demux/caf.c
=====================================
@@ -553,22 +553,22 @@ static int ProcessALACCookie( demux_t *p_demux, const uint8_t *p, uint64_t i_siz
i_extra = i_size;
}
+ free(p_sys->fmt.p_extra);
p_sys->fmt.i_extra = i_extra;
- p_sys->fmt.p_extra = malloc( i_extra );
+ p_sys->fmt.p_extra = i_extra == 0 ? NULL : malloc( i_extra );
- if( !p_sys->fmt.p_extra )
+ if( i_extra && !p_sys->fmt.p_extra )
return VLC_ENOMEM;
- uint8_t *p_extra = ( uint8_t * )p_sys->fmt.p_extra;
-
if( i_size == kALAC_NEW_KUKI_SIZE )
{
+ uint8_t *p_extra = ( uint8_t * )p_sys->fmt.p_extra;
SetDWBE( p_extra, 36 );
memcpy( p_extra + 4, "alac", 4 );
SetDWBE( p_extra + 8, 0 );
memcpy( p_extra + 12, p, 24 );
}
- else
+ else if (i_size != 0)
{
memcpy( p_sys->fmt.p_extra, p, i_size );
}
@@ -682,15 +682,18 @@ aac_kuki_finish:
i_offset = 0;
}
+ free(p_sys->fmt.p_extra);
p_sys->fmt.i_extra = i_kuki_size;
- p_sys->fmt.p_extra = malloc( i_kuki_size );
+ p_sys->fmt.p_extra = i_kuki_size == 0 ? NULL : malloc( i_kuki_size );
- if( !p_sys->fmt.p_extra )
+ if( i_kuki_size && !p_sys->fmt.p_extra )
{
return VLC_ENOMEM;
}
-
- memcpy( p_sys->fmt.p_extra, p + i_offset, i_kuki_size );
+ if ( i_kuki_size )
+ {
+ memcpy( p_sys->fmt.p_extra, p + i_offset, i_kuki_size );
+ }
return VLC_SUCCESS;
}
@@ -724,14 +727,18 @@ static int ReadKukiChunk( demux_t *p_demux, uint64_t i_size )
}
else if( p_sys->fmt.i_codec != 0 )
{
+ free(p_sys->fmt.p_extra);
p_sys->fmt.i_extra = i_size;
- p_sys->fmt.p_extra = malloc( i_size );
+ p_sys->fmt.p_extra = i_size == 0 ? NULL : malloc( i_size );
- if( !p_sys->fmt.p_extra )
+ if( i_size && !p_sys->fmt.p_extra )
{
return VLC_ENOMEM;
}
- memcpy( p_sys->fmt.p_extra, p_peek, p_sys->fmt.i_extra );
+ if ( i_size != 0)
+ {
+ memcpy( p_sys->fmt.p_extra, p_peek, p_sys->fmt.i_extra );
+ }
}
return VLC_SUCCESS;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5023026ac2e4fbe0709ac16f122fcc691e521a97...03e0366f5e7135792991ae80179bc33e99b0a9ab
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5023026ac2e4fbe0709ac16f122fcc691e521a97...03e0366f5e7135792991ae80179bc33e99b0a9ab
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