[vlc-commits] demux: ogg: rewrite headers gathering
Francois Cartegnie
git at videolan.org
Mon Nov 9 11:04:51 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 9 10:51:52 2015 +0100| [48b5ccf90d0fb2089f542b22ffc8029265579369] | committer: Francois Cartegnie
demux: ogg: rewrite headers gathering
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48b5ccf90d0fb2089f542b22ffc8029265579369
---
modules/demux/ogg.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 55726e9..ed2993b 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -1266,20 +1266,18 @@ static void Ogg_DecodePacket( demux_t *p_demux,
/* Backup the ogg packet (likely an header packet) */
if( !b_xiph )
{
- void *p_org = p_stream->p_headers;
- p_stream->i_headers += p_oggpacket->bytes;
- p_stream->p_headers = realloc( p_stream->p_headers, p_stream->i_headers );
- if( p_stream->p_headers )
+ uint8_t *p_realloc = realloc( p_stream->p_headers, p_stream->i_headers + p_oggpacket->bytes );
+ if( p_realloc )
{
- memcpy( (unsigned char *)p_stream->p_headers + p_stream->i_headers - p_oggpacket->bytes,
- p_oggpacket->packet, p_oggpacket->bytes );
+ memcpy( &p_realloc[p_stream->i_headers], p_oggpacket->packet, p_oggpacket->bytes );
+ p_stream->i_headers += p_oggpacket->bytes;
+ p_stream->p_headers = p_realloc;
}
else
{
-#warning Memory leak
+ free( p_stream->p_headers );
p_stream->i_headers = 0;
p_stream->p_headers = NULL;
- free( p_org );
}
}
else if( xiph_AppendHeaders( &p_stream->i_headers, &p_stream->p_headers,
More information about the vlc-commits
mailing list