]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mms.c
mov: Wrap stsc index and count compare in a separate function
[ffmpeg] / libavformat / mms.c
index 57966632535d6c3a99a9ce9cbc151cd8558002f9..fc967c189226eccbdf179b4c347524f722bb8607 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * MMS protocol common definitions.
  * Copyright (c) 2006,2007 Ryan Martell
- * Copyright (c) 2007 Björn Axelsson
+ * Copyright (c) 2007 Björn Axelsson
  * Copyright (c) 2010 Zhentan Feng <spyfeng at gmail dot com>
  *
  * This file is part of Libav.
 #include "asf.h"
 #include "libavutil/intreadwrite.h"
 
-#if FF_API_MAX_STREAMS
-#define MMS_MAX_STREAMS MAX_STREAMS
-#else
 #define MMS_MAX_STREAMS 256    /**< arbitrary sanity check value */
-#endif
 
 int ff_mms_read_header(MMSContext *mms, uint8_t *buf, const int size)
 {
@@ -101,13 +97,15 @@ int ff_mms_asf_header_parser(MMSContext *mms)
             flags     = AV_RL16(p + sizeof(ff_asf_guid)*3 + 24);
             stream_id = flags & 0x7F;
             //The second condition is for checking CS_PKT_STREAM_ID_REQUEST packet size,
-            //we can calcuate the packet size by stream_num.
+            //we can calculate the packet size by stream_num.
             //Please see function send_stream_selection_request().
             if (mms->stream_num < MMS_MAX_STREAMS &&
                     46 + mms->stream_num * 6 < sizeof(mms->out_buffer)) {
                 mms->streams = av_fast_realloc(mms->streams,
                                    &mms->nb_streams_allocated,
                                    (mms->stream_num + 1) * sizeof(MMSStream));
+                if (!mms->streams)
+                    return AVERROR(ENOMEM);
                 mms->streams[mms->stream_num].id = stream_id;
                 mms->stream_num++;
             } else {