mirror of https://github.com/mpv-player/mpv
{options,player}: fix stream leaks
This commit is contained in:
parent
ae23556b6f
commit
b69b58a12a
|
@ -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);
|
MP_VERBOSE(config, "Reading config file %s\n", conffile);
|
||||||
|
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
struct stream *s = stream_create(conffile, STREAM_READ | STREAM_ORIGIN_DIRECT,
|
struct stream *s = stream_create(conffile, STREAM_READ | STREAM_ORIGIN_DIRECT,
|
||||||
NULL, global);
|
NULL, global);
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
goto done;
|
||||||
bstr data = stream_read_complete(s, s, 1000000000);
|
bstr data = stream_read_complete(s, s, 1000000000);
|
||||||
if (!data.start)
|
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);
|
done:
|
||||||
talloc_free(data.start);
|
|
||||||
free_stream(s);
|
free_stream(s);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,8 @@ void error_on_track(struct MPContext *mpctx, struct track *track)
|
||||||
int stream_dump(struct MPContext *mpctx, const char *source_filename)
|
int stream_dump(struct MPContext *mpctx, const char *source_filename)
|
||||||
{
|
{
|
||||||
struct MPOpts *opts = mpctx->opts;
|
struct MPOpts *opts = mpctx->opts;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
stream_t *stream = stream_create(source_filename,
|
stream_t *stream = stream_create(source_filename,
|
||||||
STREAM_ORIGIN_DIRECT | STREAM_READ,
|
STREAM_ORIGIN_DIRECT | STREAM_READ,
|
||||||
mpctx->playback_abort, mpctx->global);
|
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");
|
FILE *dest = fopen(opts->stream_dump, "wb");
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno));
|
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) {
|
while (mpctx->stop_play == KEEP_PLAYING && ok) {
|
||||||
if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) {
|
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;
|
ok &= fclose(dest) == 0;
|
||||||
|
done:
|
||||||
free_stream(stream);
|
free_stream(stream);
|
||||||
return ok ? 0 : -1;
|
return ok ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue