[vlc-commits] access: mmstu: remove xmalloc and simplify

Francois Cartegnie git at videolan.org
Mon Dec 28 14:21:48 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec 28 14:20:34 2015 +0100| [c641af460856c81cfd6c91e2a4edc3304681f494] | committer: Francois Cartegnie

access: mmstu: remove xmalloc and simplify

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c641af460856c81cfd6c91e2a4edc3304681f494
---

 modules/access/mms/mmstu.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c
index b3c72a4..4101077 100644
--- a/modules/access/mms/mmstu.c
+++ b/modules/access/mms/mmstu.c
@@ -1297,12 +1297,16 @@ static int  mms_ParsePacket( access_t *p_access,
     }
     else
     {
-        uint8_t* p_packet = xmalloc( i_packet_length - 8 ); // don't bother with preheader
-        memcpy( p_packet, p_data + 8, i_packet_length - 8 );
-        FREENULL( p_sys->p_media );
-        p_sys->p_media = p_packet;
-        p_sys->i_media = i_packet_length - 8;
+        free( p_sys->p_media );
+        p_sys->i_media = 0;
         p_sys->i_media_used = 0;
+
+        p_sys->p_media = malloc( i_packet_length - 8 ); // don't bother with preheader
+        if( !p_sys->p_media )
+            return VLC_ENOMEM;
+
+        p_sys->i_media = i_packet_length - 8;
+        memcpy( p_sys->p_media, p_data + 8, p_sys->i_media );
 /*        msg_Dbg( p_access,
                  "receive media packet (%d bytes)",
                  i_packet_length - 8 ); */



More information about the vlc-commits mailing list