From patchwork Tue Sep 27 19:00:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sophia Wang X-Patchwork-Id: 752 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp23952vsd; Tue, 27 Sep 2016 12:08:42 -0700 (PDT) X-Received: by 10.194.147.99 with SMTP id tj3mr24360259wjb.183.1475003322263; Tue, 27 Sep 2016 12:08:42 -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 e7si3844361wjw.288.2016.09.27.12.08.39; Tue, 27 Sep 2016 12:08:42 -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 3BB34689D95; Tue, 27 Sep 2016 22:08:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 37894689A54 for ; Tue, 27 Sep 2016 22:08:19 +0300 (EEST) Received: by mail-pf0-f175.google.com with SMTP id q2so8656084pfj.3 for ; Tue, 27 Sep 2016 12:08:31 -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=sgJWexRl6BWN9gv6cSppaTiBB83ynsJp3r34OnEWPd4=; b=E9pEQW/tndAZaeFjImqNKOrSYvzTvaN/+L4e5k4BGPjgfFrET8X7EDDMqeyaDpdWYK MBlyZLMnJq1fisvswzB937WnWsJfRHRgDjXXeRrFp4kzR2ih4Vo2+Dn5VFfubDBuk+uN 3Yv5hR1hnUH6ejWSS5A7YXrxb2Rd5MdqZQ1lSurbJPhmmka4GR/3YCT97MTMRQ8XPONU jGWys/f9O2vhGCaUbWzcm4n72omIhoMQCkuTrwj/VDjYQ0alaxThc1slhSjVrWhljHEH FFJLFbWAJXHl5PoGz05FtjHGObC/W2ufQTok+o+7KyUHqIpZMlxpFsxpmBSZn35QFLDR Cd8g== 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=sgJWexRl6BWN9gv6cSppaTiBB83ynsJp3r34OnEWPd4=; b=PdK2fuRzD7xCzsnVZw8n3K6IKHXwfemgSzLgy3LMFDVFUgwnxqoNF1LAadvvanAGge wrcPIZrlJf3UeK0dSVBVwVHGIYyxTiRgLqxc2bK3qbn/S642gH6U+FIaMxhpA2nNvuel y9e5SERBbbbt5p+cnjQqzBsQEt+fO9J2zumFg0KCrIyhwFJctnV/tMohv6pPh8iJy6XO KBHqBnf5aTVvqdS/pB0ODzbUzZJhAFUOQ/acibeq9pGMC+urXIr5He8+9SpzTzGodIJF puED8vZATDl4vtifvPnADsmBb3RDK9Yw1yHLdXzo1akdXa75PlYyMWtRZzuXRDhc90WU wHmw== X-Gm-Message-State: AE9vXwNLVsXdBV27QnT0pKOeOvaVBgoJDAu6kCUfTBDErqT18wF3baqz41GTLrYfaY2FdXxA X-Received: by 10.98.101.66 with SMTP id z63mr50120422pfb.59.1475002836217; Tue, 27 Sep 2016 12:00:36 -0700 (PDT) Received: from skw0.mtv.corp.google.com ([172.27.82.56]) by smtp.gmail.com with ESMTPSA id ak3sm6688610pad.19.2016.09.27.12.00.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 12:00:35 -0700 (PDT) From: Sophia Wang To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Sep 2016 12:00:29 -0700 Message-Id: <1475002829-11427-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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 77b8a5d..7ee1c7a 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,16 +3319,17 @@ 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; + return ret; } static int matroska_read_seek(AVFormatContext *s, int stream_index,