Commit 834d3847 authored by Rémi Duraffort's avatar Rémi Duraffort

mms/mmstu: fix a memleak and avoid to memcpy two times the same thing

(but yes duplicate 2 lines of code).
parent 428d84df
...@@ -1256,9 +1256,6 @@ static int mms_ParsePacket( access_t *p_access, ...@@ -1256,9 +1256,6 @@ static int mms_ParsePacket( access_t *p_access,
size_t i_packet_length; size_t i_packet_length;
uint32_t i_packet_id; uint32_t i_packet_id;
uint8_t *p_packet;
*pi_used = i_data; /* default */ *pi_used = i_data; /* default */
if( i_data <= 8 ) if( i_data <= 8 )
{ {
...@@ -1300,9 +1297,6 @@ static int mms_ParsePacket( access_t *p_access, ...@@ -1300,9 +1297,6 @@ static int mms_ParsePacket( access_t *p_access,
} }
/* we now have a media or a header packet */ /* we now have a media or a header packet */
p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
memcpy( p_packet, p_data + 8, i_packet_length - 8 );
if( i_packet_seq_num != p_sys->i_packet_seq_num ) if( i_packet_seq_num != p_sys->i_packet_seq_num )
{ {
#if 0 #if 0
...@@ -1322,14 +1316,14 @@ static int mms_ParsePacket( access_t *p_access, ...@@ -1322,14 +1316,14 @@ static int mms_ParsePacket( access_t *p_access,
p_sys->p_header = realloc( p_sys->p_header, p_sys->p_header = realloc( p_sys->p_header,
p_sys->i_header + i_packet_length - 8 ); p_sys->i_header + i_packet_length - 8 );
memcpy( &p_sys->p_header[p_sys->i_header], memcpy( &p_sys->p_header[p_sys->i_header],
p_packet, p_data + 8, i_packet_length - 8 );
i_packet_length - 8 );
p_sys->i_header += i_packet_length - 8; p_sys->i_header += i_packet_length - 8;
free( p_packet );
} }
else else
{ {
uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
memcpy( p_packet, p_data + 8, i_packet_length - 8 );
p_sys->p_header = p_packet; p_sys->p_header = p_packet;
p_sys->i_header = i_packet_length - 8; p_sys->i_header = i_packet_length - 8;
} }
...@@ -1341,6 +1335,8 @@ static int mms_ParsePacket( access_t *p_access, ...@@ -1341,6 +1335,8 @@ static int mms_ParsePacket( access_t *p_access,
} }
else else
{ {
uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
memcpy( p_packet, p_data + 8, i_packet_length - 8 );
FREENULL( p_sys->p_media ); FREENULL( p_sys->p_media );
p_sys->p_media = p_packet; p_sys->p_media = p_packet;
p_sys->i_media = i_packet_length - 8; p_sys->i_media = i_packet_length - 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment