1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00

{options,player}: fix stream leaks

This commit is contained in:
sfan5 2024-05-13 21:36:36 +02:00
parent ae23556b6f
commit b69b58a12a
2 changed files with 11 additions and 6 deletions

View File

@ -163,16 +163,18 @@ int m_config_parse_config_file(m_config_t *config, struct mpv_global *global,
MP_VERBOSE(config, "Reading config file %s\n", conffile);
int r = 0;
struct stream *s = stream_create(conffile, STREAM_READ | STREAM_ORIGIN_DIRECT,
NULL, global);
if (!s)
return 0;
goto done;
bstr data = stream_read_complete(s, s, 1000000000);
if (!data.start)
return 0;
goto done;
r = m_config_parse(config, conffile, data, initial_section, flags);
int r = m_config_parse(config, conffile, data, initial_section, flags);
talloc_free(data.start);
done:
free_stream(s);
return r;
}

View File

@ -266,6 +266,8 @@ void error_on_track(struct MPContext *mpctx, struct track *track)
int stream_dump(struct MPContext *mpctx, const char *source_filename)
{
struct MPOpts *opts = mpctx->opts;
bool ok = false;
stream_t *stream = stream_create(source_filename,
STREAM_ORIGIN_DIRECT | STREAM_READ,
mpctx->playback_abort, mpctx->global);
@ -277,10 +279,10 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
FILE *dest = fopen(opts->stream_dump, "wb");
if (!dest) {
MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno));
return -1;
goto done;
}
bool ok = true;
ok = true;
while (mpctx->stop_play == KEEP_PLAYING && ok) {
if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) {
@ -300,6 +302,7 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
}
ok &= fclose(dest) == 0;
done:
free_stream(stream);
return ok ? 0 : -1;
}