From 42845e4867559f274226a0d60aa8b00d58eee53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sat, 8 Dec 2018 12:27:40 -0500 Subject: [PATCH] cli: don't increment the absolute page number on error --- src/cli.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli.cc b/src/cli.cc index 300496d..b19604e 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -185,15 +185,16 @@ static ot::status edit_tags(ot::opus_tags& tags, const ot::options& opt) static ot::status process(ot::ogg_reader& reader, ot::ogg_writer* writer, const ot::options &opt) { /** \todo Become stream-aware instead of counting the pages of all streams together. */ - int absolute_page_no; /*< page number in the physical stream, not logical */ - for (absolute_page_no = 0;; ++absolute_page_no) { + int absolute_page_no = -1; /*< page number in the physical stream, not logical */ + for (;;) { ot::status rc = reader.next_page(); if (rc == ot::st::end_of_stream) break; - else if (rc == ot::st::bad_stream && absolute_page_no == 0) + else if (rc == ot::st::bad_stream && absolute_page_no == -1) return {ot::st::bad_stream, "Input is not a valid Ogg file."}; else if (rc != ot::st::ok) return rc; + ++absolute_page_no; auto serialno = ogg_page_serialno(&reader.page); auto pageno = ogg_page_pageno(&reader.page); if (absolute_page_no == 0) { // Identification header