[FFmpeg-soc] [soc]: r5745 - mms/mmst.c

spyfeng subversion at mplayerhq.hu
Thu Apr 8 18:24:58 CEST 2010


Author: spyfeng
Date: Thu Apr  8 18:24:58 2010
New Revision: 5745

Log:
fix possible memory leak when av_realloc() failure.

Modified:
   mms/mmst.c

Modified: mms/mmst.c
==============================================================================
--- mms/mmst.c	Thu Apr  8 18:02:41 2010	(r5744)
+++ mms/mmst.c	Thu Apr  8 18:24:58 2010	(r5745)
@@ -259,6 +259,7 @@ static MMSSCPacketType get_tcp_server_re
     int read_result;
     MMSSCPacketType packet_type= -1;
     int done;
+    uint8_t *p;
 
     do {
         done= 1;
@@ -323,13 +324,14 @@ static MMSSCPacketType get_tcp_server_re
                         packet_type = SC_PKT_ASF_HEADER;
                         // Store the asf header
                         if(!mms->header_parsed) {
-                            mms->asf_header = av_realloc(mms->asf_header,
+                            p = av_realloc(mms->asf_header,
                                               mms->asf_header_size
                                               + mms->pkt_buf_len);
-                            if (!mms->asf_header) {
+                            if (!p) {
                                 av_freep(&mms->asf_header);
                                 return AVERROR(ENOMEM);
-                            }
+                            } else
+                                mms->asf_header = p;
                             memcpy(mms->asf_header + mms->asf_header_size,
                                                  mms->pkt_read_ptr,
                                                  mms->pkt_buf_len);


More information about the FFmpeg-soc mailing list