From d50de74c1ee79ada5d27b465a9074b0ebf87cedf Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 1 Oct 2023 15:35:57 -0500 Subject: Revert "demux: constify a struct member" Some demuxers actually close the stream right after they are finished opening like cue. Since the stream->url is no longer copied with this commit, that means it gets thrown away after the stream closes. This leads to a use after free. We still need to allocate stream->url so fix this another way. This reverts commit 3e85df3b2d89d6a27806d677b6b8a99055cb1fcc. --- demux/demux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 955f84cb81..2b1e670b28 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -3245,7 +3245,7 @@ struct parent_stream_info { bool is_streaming; int stream_origin; struct mp_cancel *cancel; - const char *filename; + char *filename; }; static struct demuxer *open_given_type(struct mpv_global *global, @@ -3415,7 +3415,7 @@ static struct demuxer *demux_open(struct stream *stream, .is_streaming = stream->streaming, .stream_origin = stream->stream_origin, .cancel = cancel, - .filename = stream->url, + .filename = talloc_strdup(NULL, stream->url), }; // Test demuxers from first to last, one pass for each check_levels[] entry @@ -3437,6 +3437,7 @@ static struct demuxer *demux_open(struct stream *stream, } done: + talloc_free(sinfo.filename); talloc_free(log); return demuxer; } -- cgit v1.2.3