From patchwork Tue Aug 2 20:11:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sophia Wang X-Patchwork-Id: 71 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp380151vsd; Tue, 2 Aug 2016 13:13:07 -0700 (PDT) X-Received: by 10.194.145.103 with SMTP id st7mr57338819wjb.61.1470168787824; Tue, 02 Aug 2016 13:13:07 -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 z6si22923899wmg.146.2016.08.02.13.13.07; Tue, 02 Aug 2016 13:13:07 -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 39449689FCF; Tue, 2 Aug 2016 23:12:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3CD43689E6E for ; Tue, 2 Aug 2016 23:12:45 +0300 (EEST) Received: by mail-pa0-f44.google.com with SMTP id pp5so66313152pac.3 for ; Tue, 02 Aug 2016 13:12:51 -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=5cQ9R6aO7pvGKZdIEzBRERRka9Ut58QHOFzP5AHWFis=; b=Qfs4xD0IGSXbaZwftfahO8I7kN7NktfFcaIubAhfDDuaiCJxrlsB1tFXbGvGHqhsqu 4g4F4SSXNYDB0W3SgBV+tWqOb0mUfzR+9mXXkwE/aUG+F9rIC8A79Nd6EX9wSN5dzFqe hq6SAVyRqbNOJkchBOtDEZax1WapT7lPOigKF3pDjttylVBhmv/i/P1DTjiiJaj+raKI SG5FNFq3GjjNJ9QIj0cB/B9SYlOpjGbriIi0jemN3UTeAKFfV7rSjvjVpg6u++6ObY51 2VDZXlo/H2IJqrmLEcGDLH3aGtGkv7vCNDESw05RSBURqNX9LNtrNKSlHawxOBoKIzyk Ei3A== 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=5cQ9R6aO7pvGKZdIEzBRERRka9Ut58QHOFzP5AHWFis=; b=Vxb+dgHCh1v/D+R6aCtVCWKj22ot6AbZnY5KMinrz+egPkPpLo588kAW/VPDS8qTaN bnuj6dryL64Oon8ky/0s57DlJ4yJSpRnWZHobHUMh0sgyPkgkwSUteMbh+UZH5jTxx6p 38oJUbdf9xVUZoZGL58JVEZhNfOcXWWrkq94/DcDUtN7e5iMb7/tw+GI++r9VdCxHRaE yJI519pG4hNE4jWBIf7hziaXvZXTV2Y3HRV93Gy6NWWyF7VbDgLXWol18Cs5C9NfF5A9 wBo3uqvAk9BfW9/fuk81VVI3tabhRW2RXdKnbXPpYplb6zfuekpAz7wrLY/03InaVBRj pQGg== X-Gm-Message-State: AEkooutHdPkuIIIABeNjSflGwLCp5zWljebcnUPSG0Gyw5fDKOIAGbS3fWsuVThdIaGBR7Lg X-Received: by 10.66.79.138 with SMTP id j10mr48045069pax.60.1470168769513; Tue, 02 Aug 2016 13:12:49 -0700 (PDT) Received: from skw0.mtv.corp.google.com ([172.27.82.56]) by smtp.gmail.com with ESMTPSA id l191sm6799386pfc.91.2016.08.02.13.12.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 13:12:48 -0700 (PDT) From: Sophia Wang To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Aug 2016 13:11:57 -0700 Message-Id: <1470168717-49482-1-git-send-email-skw@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1469222229-76207-1-git-send-email-skw@google.com> References: <1469222229-76207-1-git-send-email-skw@google.com> 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 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d07a092..f9693ca 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; } @@ -3322,13 +3324,14 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; + int ret; while (matroska_deliver_packet(matroska, pkt)) { int64_t pos = avio_tell(matroska->ctx->pb); - if (matroska->done) - return AVERROR_EOF; - if (matroska_parse_cluster(matroska) < 0) - matroska_resync(matroska, pos); + if (matroska_parse_cluster(matroska) < 0) { + if ((ret = matroska_resync(matroska, pos)) < 0) + return ret; + } } return 0;