From patchwork Mon Mar 2 04:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17999 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id AD59B449CCD for ; Mon, 2 Mar 2020 06:45:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A08B268B4BA; Mon, 2 Mar 2020 06:45:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B763068B396 for ; Mon, 2 Mar 2020 06:45:06 +0200 (EET) Received: by mail-wr1-f50.google.com with SMTP id e10so9326332wrr.10 for ; Sun, 01 Mar 2020 20:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QxXgAxgFJYFkdbu0qZIbKzRByF/0swANtfwhA43KkJU=; b=qrFvAPfr1N6goMLn4g7eNhZrhH9jEa63UZsp1O5WbiC69AebxSGwrJ594LB3NebSGl iNaxlOafv0qNuFJcalWohJA/JjK1zqFx0N6UJmzN8KUX09WcYSxUz6fAOGMjdfAvdT9W U+nBOSzcrFXAbzo3J5Ie6KHRywjGYZoa3TC9ASJE3oCCoveRrESYsrUQgjKJY29O9loc d4QnjsVeHhGbwOtxYk57OiBeI0mwjGkwEi7cSWWvBNwy9jt0fS5w0pfOTpjCw+rjNzAS Cq7c/D6GlmmmySoE7VQkVb3MuIdbr22isjaC0xYqrcvQfhMtxS3+9jCyoBVDq2x5IKYu nXXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QxXgAxgFJYFkdbu0qZIbKzRByF/0swANtfwhA43KkJU=; b=XSyAUWKUpx+DA529EqRblWHNQerpCzCu1vTgWmRSwAgfLRrl7H5dqotU936UN5ziXF HCjz3nQBqymPCeVGRDWENR8s0OyJSDy7RrqIQ0dIKmtAYCXVfcvE9D6RCV5qx/npkYQk wv/tEmv9ubAwhfpB4EE5rrFf31798Ih5XBGwRHAn5dixPcZxHNpnm1fxlqeZK+JvQVIF msfHJdGE5OMsHHO6Gzd6rW70rKPmruZQ8OGffg3VovWFwi5GpOfiLRa80jnm3IbvHba7 OwrQEIQhdVr6dGLIGEPRTaOLCDr6RGPKsqL1Jqncnld6DlTpnMKIhIjWDJnkZkKzCR2I ieeg== X-Gm-Message-State: APjAAAXwoDexPo35N5mUoYAlCK+wjLDxngSlarhhscVSNzDwOZVbv2b7 Av8g0Iz+IqwHg4YkuXxwCXNoN5tQ X-Google-Smtp-Source: APXvYqw/xPSq42e3tFLetSbPz0HrIXOtT4t1k62WwHjFDVye4PrlawChFAsqTJIPTXmmzgS+a6vujQ== X-Received: by 2002:adf:c445:: with SMTP id a5mr19731241wrg.14.1583124305801; Sun, 01 Mar 2020 20:45:05 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1ab4b.dynamic.kabel-deutschland.de. [188.193.171.75]) by smtp.gmail.com with ESMTPSA id s22sm13130229wmc.16.2020.03.01.20.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:45:05 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Mar 2020 05:44:44 +0100 Message-Id: <20200302044445.14842-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> References: <20200302043520.14165-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/17] avformat/webm_chunk: Check unchecked functions for errors 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/webm_chunk.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 6ffe952eff..8f1f884c98 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -95,7 +95,8 @@ static int webm_chunk_init(AVFormatContext *s) oc->flush_packets = 0; - av_dict_copy(&oc->metadata, s->metadata, 0); + if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0) + return ret; if (!(st = avformat_new_stream(oc, NULL))) return AVERROR(ENOMEM); @@ -109,11 +110,14 @@ static int webm_chunk_init(AVFormatContext *s) avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num, ost->time_base.den); - av_dict_set_int(&dict, "dash", 1, 0); - av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0); - av_dict_set_int(&dict, "live", 1, 0); + if ((ret = av_dict_set_int(&dict, "dash", 1, 0)) < 0 || + (ret = av_dict_set_int(&dict, "cluster_time_limit", + wc->chunk_duration, 0)) < 0 || + (ret = av_dict_set_int(&dict, "live", 1, 0)) < 0) + goto fail; ret = avformat_init_output(oc, &dict); +fail: av_dict_free(&dict); if (ret < 0) return ret; @@ -155,7 +159,8 @@ static int webm_chunk_write_header(AVFormatContext *s) AVDictionary *options = NULL; if (wc->http_method) - av_dict_set(&options, "method", wc->http_method, 0); + if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) + return ret; ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options); av_dict_free(&options); if (ret < 0) @@ -205,14 +210,15 @@ static int chunk_end(AVFormatContext *s, int flush) if (ret < 0) goto fail; if (wc->http_method) - av_dict_set(&options, "method", wc->http_method, 0); + if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0) + goto fail; ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options); + av_dict_free(&options); if (ret < 0) goto fail; avio_write(pb, buffer, buffer_size); ff_format_io_close(s, &pb); fail: - av_dict_free(&options); av_free(buffer); return (ret < 0) ? ret : 0; } @@ -260,7 +266,9 @@ static int webm_chunk_write_trailer(AVFormatContext *s) if (ret < 0) return ret; } - av_write_trailer(oc); + ret = av_write_trailer(oc); + if (ret < 0) + return ret; return chunk_end(s, 0); }