aboutsummaryrefslogtreecommitdiffstats
path: root/ffserver.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2010-10-15 19:09:05 +0000
committerAurelien Jacobs <aurel@gnuage.org>2010-10-15 19:09:05 +0000
commit9389b925f13160bb421fd69ebc9522477af77fdf (patch)
tree668b1b9332171127cf1b0a640d1a73e3def3a8b0 /ffserver.c
parent03700d399bcc749ad7916f2d39a99527f37c8b6e (diff)
downloadffmpeg-9389b925f13160bb421fd69ebc9522477af77fdf.tar.gz
ffserver: fix prepare_sdp_description() to dynamically allocate streams
Originally committed as revision 25494 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffserver.c')
-rw-r--r--ffserver.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/ffserver.c b/ffserver.c
index d5d841768d..4693cc7b3c 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2930,7 +2930,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
- AVStream avs[MAX_STREAMS];
+ AVStream *avs = NULL;
int i;
avc = avformat_alloc_context();
@@ -2948,14 +2948,29 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
snprintf(avc->filename, 1024, "rtp://0.0.0.0");
}
+#if !FF_API_MAX_STREAMS
+ if (avc->nb_streams >= INT_MAX/sizeof(*avc->streams) ||
+ !(avc->streams = av_malloc(avc->nb_streams * sizeof(*avc->streams))))
+ goto sdp_done;
+#endif
+ if (avc->nb_streams >= INT_MAX/sizeof(*avs) ||
+ !(avs = av_malloc(avc->nb_streams * sizeof(*avs))))
+ goto sdp_done;
+
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
avf_sdp_create(&avc, 1, *pbuffer, 2048);
+
+ sdp_done:
+#if !FF_API_MAX_STREAMS
+ av_free(avc->streams);
+#endif
av_metadata_free(&avc->metadata);
av_free(avc);
+ av_free(avs);
return strlen(*pbuffer);
}