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

Francois Cartegnie git at videolan.org
Mon Dec 28 23:35:53 CET 2015


vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec 28 14:20:34 2015 +0100| [53a6c7ecf7472ceb606dc658916239d575e04cbd] | committer: Jean-Baptiste Kempf

access: mmstu: remove xmalloc and simplify

(cherry picked from commit c641af460856c81cfd6c91e2a4edc3304681f494)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 7723af4..c81900e 100644
--- a/modules/access/mms/mmstu.c
+++ b/modules/access/mms/mmstu.c
@@ -1308,12 +1308,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