From patchwork Thu Sep 22 21:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sophia Wang X-Patchwork-Id: 688 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp223639vsd; Thu, 22 Sep 2016 14:03:50 -0700 (PDT) X-Received: by 10.194.135.76 with SMTP id pq12mr3769021wjb.114.1474578230002; Thu, 22 Sep 2016 14:03:50 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l2si3914443wjg.109.2016.09.22.14.03.45; Thu, 22 Sep 2016 14:03:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5ABDE689D47; Fri, 23 Sep 2016 00:03:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50567689BC8 for ; Fri, 23 Sep 2016 00:03:20 +0300 (EEST) Received: by mail-pf0-f182.google.com with SMTP id p64so34270719pfb.1 for ; Thu, 22 Sep 2016 14:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nmsjWuyCVwpCS9i6xMCw5JUVaS2HTGm7bC3Y5oO9Mr4=; b=ZOmnKwddwwpF/HlIZ0IFCt3WMgMR53Ts3+pdUtAQUFTppc8cCK6P+akF8xAiMLDnX2 Q+S3cMo+zO690sjXy+2B2jveUWHbueqCGoVh1Zd/omb7OU7sUYvmQ5FwoKBB/U2jgUR/ 0teSf9g+B7jewNrtueU3fVoM/NPcaBxWNPQG4FRRSCBersmE5STZgZpf4O1eMOV11/JI EmvoPSg8f7kbr+sQ/ykLxfFojqUxJ/mXJyDZZlw6j6zwTreOcqTu2OI4hAk/ThSYiKnQ sWVnqumKYIjoZiJXj1rMZO4JgXisUqrSsYQ6vKkckE97RdJGjKtrQp/cqXUivql/z01m MQxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nmsjWuyCVwpCS9i6xMCw5JUVaS2HTGm7bC3Y5oO9Mr4=; b=T5isX5VHSu3gNgxtC/j8hZItqC83WG1A2I+Lb2eua9KK5wavBIA4sqVyEFKtLYSU2o jSckDVOW5al9D+/vOy0b0Z2m/4PVqOKgntv83WzVajhgBtqcWqSK16PgONNjFZFlhI7g 2WEuXP/LKoAwkksv50oY+jSi6xQS74eGfLGJv6DCQO0xH5W2RYAOVVdX+gCHYyulGwTz uS5e3MVKi3VhKihjsmkWPwbQhrhgqmWFgWhmFenaKiIJFyWuGtaYkQPKV76ZCMX3OxrD XCQrpzRnl3FRUVxLoLN2rhQFB1+CxpyusFZxaKqTfghZdBIR+S/+18eAReNQnGoOECbg IjyA== X-Gm-Message-State: AE9vXwPS1PmuPn8/UHdPAtFLc+aTN28Us1lXj2j4yyrKY7Chx2WiM8LyV+2yeKX2YYbc/MEJ X-Received: by 10.98.204.207 with SMTP id j76mr6678423pfk.6.1474578214702; Thu, 22 Sep 2016 14:03:34 -0700 (PDT) Received: from skw0.mtv.corp.google.com ([172.27.82.56]) by smtp.gmail.com with ESMTPSA id u64sm6196154pfi.0.2016.09.22.14.03.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 14:03:33 -0700 (PDT) From: Sophia Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2016 14:03:09 -0700 Message-Id: <1474578189-135377-1-git-send-email-skw@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] avformat/matroskadec: retain error codes in matroska_resync() and matroska_read_packet() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Sophia Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Sophia Wang --- libavformat/matroskadec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 77b8a5d..936690d 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -738,13 +738,16 @@ static int matroska_read_close(AVFormatContext *s); static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) { AVIOContext *pb = matroska->ctx->pb; + int64_t ret; uint32_t id; matroska->current_id = 0; matroska->num_levels = 0; /* seek to next position to resync from */ - if (avio_seek(pb, last_pos + 1, SEEK_SET) < 0) - goto eof; + if ((ret = avio_seek(pb, last_pos + 1, SEEK_SET)) < 0) { + matroska->done = 1; + return ret; + } id = avio_rb32(pb); @@ -760,7 +763,6 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) id = (id << 8) | avio_r8(pb); } -eof: matroska->done = 1; return AVERROR_EOF; } @@ -3317,13 +3319,14 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; + int ret = 0; while (matroska_deliver_packet(matroska, pkt)) { int64_t pos = avio_tell(matroska->ctx->pb); if (matroska->done) - return AVERROR_EOF; + return (ret < 0) ? ret : AVERROR_EOF; if (matroska_parse_cluster(matroska) < 0) - matroska_resync(matroska, pos); + ret = matroska_resync(matroska, pos); } return 0;