hlsdemux2: Fix parsing of byterange and init map directives

Don't reuse the same offset and size variables when reading
the byterange out of a MAP directive, as it can overwrite
values from a pending BYTERANGE directive for the next
fragment URI.

Fixes problems where the EXT-X-MAP directive has been written
into the playlist between an EXT-X-BYTERANGE and the fragment
URI it applies to.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9533>
This commit is contained in:
Jan Schmidt 2025-08-11 22:54:29 +10:00 committed by GStreamer Marge Bot
parent fd6168709c
commit cdf1338e6b

View File

@ -1075,6 +1075,7 @@ gst_hls_media_playlist_parse (gchar * data,
}
} else if (g_str_has_prefix (data_ext_x, "MAP:")) {
gchar *v, *a, *header_uri = NULL;
gint64 init_size = -1, init_offset = -1;
data = data + 11;
@ -1083,11 +1084,11 @@ gst_hls_media_playlist_parse (gchar * data,
header_uri =
uri_join (self->base_uri ? self->base_uri : self->uri, v);
} else if (strcmp (a, "BYTERANGE") == 0) {
if (!int64_from_string (v, &v, &size)) {
if (!int64_from_string (v, &v, &init_size)) {
g_free (header_uri);
goto next_line;
}
if (*v == '@' && !int64_from_string (v + 1, &v, &offset)) {
if (*v == '@' && !int64_from_string (v + 1, &v, &init_offset)) {
g_free (header_uri);
goto next_line;
}
@ -1096,7 +1097,8 @@ gst_hls_media_playlist_parse (gchar * data,
if (header_uri) {
GstM3U8InitFile *init_file;
init_file = gst_m3u8_init_file_new (header_uri, size, offset);
init_file =
gst_m3u8_init_file_new (header_uri, init_size, init_offset);
if (last_init_file)
gst_m3u8_init_file_unref (last_init_file);