From patchwork Mon May 20 23:02:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 13210 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 E8FC94473DF for ; Tue, 21 May 2019 02:08:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CCE4968A7C4; Tue, 21 May 2019 02:08:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B3F868A3DF for ; Tue, 21 May 2019 02:08:47 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id e15so16386519wrs.4 for ; Mon, 20 May 2019 16:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YyR8otjVLCTsfW1oRHzhEYQ7V8VfA5fTqBWYTcSMAwg=; b=DmHDi4cekYL9OTtHX+NbCKbmo12dTCmMQ52KtLsGJGOXozdPlRnWZPOTy+ABP59dZZ aBv/XTGtvxKAIEDRWFhnINUL4d7U7u5jXSn7Pd+uULcFc/8jLhZWQBImEmh274JE3F6A wGziMl89Hx3dLXF2aJE8v+qp+Z83y5atO0itfL+QSbc/RRAjpYmo5q25hyY7DXOgAsKJ NFtnEW/PAWjT66tXgXF5fJ3APuW1oZ3tvHpXTadlkks5mY6y7exyAtow6I+YSLS19wBk 85ZAZu8tqpsq+O5bLmnWQSoG/xdozD2E5y4feZaHZbZdEMiYPHh/2JNts4HchxC3Y3Lj I1PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YyR8otjVLCTsfW1oRHzhEYQ7V8VfA5fTqBWYTcSMAwg=; b=csq2tXziEyPg21U1mBSJ+V1EBrOqKIawdSvC3sFWR7Rik3J81ykZkiCVQT1o8b/lOC TCsiiSmQAtLza5aYsHlzmGiN5uTMlI1aL3JUfv/vkLGReDvhTWMP03KYuc2Z1vMHeVKu yzCZU3FvVwgdBvAnnRZk80CuYbvUe5L7eiCvbYudMw+vM3kjWsGV3UmBSB8ZH4upWw45 lJGHtpCSJpSeIYtdMm3pNUQAj0HHTr4RUr/Q+XFyCONFEhiO9CTG+bCnbKKu3YBQm+fD rA4ki9aNS455j2OkOwe1aba0bwg3Ww9/7LDjxe1SWUKlUHA1jFzYkFjvjJWeog3AcePs nYEw== X-Gm-Message-State: APjAAAWxWv9UxM567NNu4g8osJ/udWbAnP1DjQ1fc6nhV9LCd5DY2hWI UJ7UUfkBsY8KtWJSk+Wdq/hCuJmLNzE= X-Google-Smtp-Source: APXvYqxl1WdaQzG2KtGrxePUmiKqfAe/z7GIYweb6K4GctcSaJdXxZiuNR8YcdxYkqBJHlBgdccCOQ== X-Received: by 2002:adf:c149:: with SMTP id w9mr36967640wre.40.1558393355164; Mon, 20 May 2019 16:02:35 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id z14sm13858538wrq.22.2019.05.20.16.02.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 16:02:34 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 May 2019 00:02:20 +0100 Message-Id: <20190520230224.19221-7-sw@jkqxz.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520230224.19221-1-sw@jkqxz.net> References: <20190520230224.19221-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 07/11] cbs_h2645: Ensure that non-refcounted parameter sets are fully copied 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Only copying the main structure is not necessarily sufficient - there could be references to substructures. --- libavcodec/cbs_h2645.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index e10bb2c62b..0b0996829c 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -700,18 +700,20 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \ H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \ unsigned int id = ps_var->id_element; \ + int err; \ if (id > FF_ARRAY_ELEMS(priv->ps_var)) { \ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid " #ps_name \ " id : %d.\n", id); \ return AVERROR_INVALIDDATA; \ } \ + err = ff_cbs_make_unit_refcounted(ctx, unit); \ + if (err < 0) \ + return err; \ if (priv->ps_var[id] == priv->active_ ## ps_var) \ priv->active_ ## ps_var = NULL ; \ av_buffer_unref(&priv->ps_var ## _ref[id]); \ - if (unit->content_ref) \ - priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ - else \ - priv->ps_var ## _ref[id] = av_buffer_alloc(sizeof(*ps_var)); \ + av_assert0(unit->content_ref); \ + priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ if (!priv->ps_var ## _ref[id]) \ return AVERROR(ENOMEM); \ priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \