prevent integer overflow in calculating duration

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
John Wimer 2011-01-17 16:00:17 +01:00 committed by Martin Storsjö
parent 348b8218f7
commit b79c3df088

View File

@ -306,7 +306,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* If this isn't a live stream, calculate the total duration of the /* If this isn't a live stream, calculate the total duration of the
* stream. */ * stream. */
if (c->finished) { if (c->finished) {
int duration = 0; int64_t duration = 0;
for (i = 0; i < c->variants[0]->n_segments; i++) for (i = 0; i < c->variants[0]->n_segments; i++)
duration += c->variants[0]->segments[i]->duration; duration += c->variants[0]->segments[i]->duration;
s->duration = duration * AV_TIME_BASE; s->duration = duration * AV_TIME_BASE;