diff --git a/libavformat/hls.c b/libavformat/hls.c index 9a4c6304e7..b03201c690 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -454,6 +454,11 @@ static struct segment *new_init_section(struct playlist *pls, ptr = strchr(info->byterange, '@'); if (ptr) sec->url_offset = strtoll(ptr+1, NULL, 10); + if (sec->size < 0 || sec->url_offset < 0 || sec->size > INT64_MAX - sec->url_offset) { + av_freep(&sec->url); + av_free(sec); + return NULL; + } } else { /* the entire file is the init section */ sec->size = -1;