From 57a4c0d5a0c1737f2e0d7beaa0cb31da04e2f4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Sat, 31 Oct 2020 18:36:56 +0100 Subject: [PATCH] =?UTF-8?q?Flush=20the=20writer=20before=20exec=E2=80=99in?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the unlikely event the child process fails without exec’ing, we don’t want both the child process and parent process to flush the OpusHead header. Thanks @omar-polo for reporting this! --- src/cli.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cli.cc b/src/cli.cc index 324729a..261ada8 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -382,9 +382,11 @@ static ot::status process(ot::ogg_reader& reader, ot::ogg_writer* writer, const if ((rc = edit_tags(tags, opt)) != ot::st::ok) return rc; if (writer) { - if (opt.edit_interactively && - (rc = edit_tags_interactively(tags, writer->path)) != ot::st::ok) - return rc; + if (opt.edit_interactively) { + fflush(writer->file); // flush before calling the subprocess + if ((rc = edit_tags_interactively(tags, writer->path)) != ot::st::ok) + return rc; + } auto packet = ot::render_tags(tags); rc = writer->write_header_packet(serialno, pageno, packet); if (rc != ot::st::ok)