From patchwork Thu Sep 12 02:52:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51529 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp672863vqi; Wed, 11 Sep 2024 20:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgrx3uJqCooHMFWC12PhBvxym5pAXu5T/ooXqKtYS8CCKtjNIHbAzOZrheVU6/vnjBz1Ed77N6UKjbCP0scUIJ@gmail.com X-Google-Smtp-Source: AGHT+IEu4j5f35zSAVjSZVAYXjNTI6BrmdMnkLvDYM0u/pTaZUsXfPwTGDjt91kn2a9YOOMoyNya X-Received: by 2002:a05:6512:398c:b0:535:63a9:9d8c with SMTP id 2adb3069b0e04-53678fba292mr652063e87.17.1726111151611; Wed, 11 Sep 2024 20:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726111151; cv=none; d=google.com; s=arc-20240605; b=YuGR3ib9nrp0TxStmGxGaZfrsmlCGdwdD2SpMyye/IQ29ltPxJPxkqSNMPpzbSs71U 6EUSNFiFEFn6LVXaJ433/TjYkWUn7pZhq8mYpyKFgN3KDyEyYR8lioZSQ27bs+SnQs3Y /iwEkAw8SefoKt+kE5Cqr/zaQ7FqW9BlnTo4GllV9CBzRtZvMLu5Y6xtDh/y9wcXTZvx cU1hmVZ63RbyojCIUTuxakQ0GfsUbhUTK4eNvawtaGZnGfZhjSIL2F/51CuCpZnOQjQf Z7+l1UV4xIYRbv3PZ2wXzGjcsWtnLjggxy8+FSr8foeBpv5BGoc2/XoFLEtM9m+2YZEf Gz3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:date:from:to:message-id:dkim-signature :delivered-to; bh=Iu5Mda1/be4mqyR7VvCz83BvLZH6bvWnY1OQpUsMPZ0=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=XwyJzhnQQzENoW/8UoXgwI0NnQePjneYM6lfUH8RJRgiOS/rslAnqJHZNUzYtECbt5 8UjUgxhltb8sqKZ+tdSHECH4evG3NvbjIRby6U+r8qrvNiA+YGdTwiYs4EPW279wm413 m2z1aYzpjvzwVGhShjkg3oDNPSVx4YNI+WsNTREVZuMec0zb3KqM5Sz1v53s0m/I003P YdcJ7Xs+7BpSwVdoSWGuZwfe1Q4hF82Paj5z1dZLCbCl76uHcHJmUC9H/VlYRZU2IQhd /Li4IsYjJRSdHlCxFLgvqa9KNDSCOkdGO4s01aXhnOltEefoTcE9GyF8HvglL1T/Q6lZ ZeZA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=QDtJ0Z6i; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5365f866342si3537723e87.124.2024.09.11.20.19.10; Wed, 11 Sep 2024 20:19:11 -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=@gmail.com header.s=20230601 header.b=QDtJ0Z6i; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 129DC68D9B9; Thu, 12 Sep 2024 05:59:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 725A468D51F for ; Thu, 12 Sep 2024 05:59:16 +0300 (EEST) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-42cd74c0d16so3957205e9.1 for ; Wed, 11 Sep 2024 19:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109955; x=1726714755; darn=ffmpeg.org; h=subject:date:from:to:message-id:from:to:cc:subject:date:message-id :reply-to; bh=wssfUvhyRjIM5BP83GJrAm9x0RXTtZGMa0VtBsQ7hyY=; b=QDtJ0Z6i8x95XnZAzL0Q9DfLadnZcYpDhv71hOMr0bYCZy5AcG0SDMMrwuYw6wUb94 bcMSp5H/LlbUWq3rr+V0zZwWffID7QP11pAekN7KsB5YtbZh1pN0hayU2YA8X+2f7BsD Mx1+YAHNx1uWC1yervUqrn5JX+xKQhXP+wJGCtggechRqcgpXUynlZ6A6032hHgKcFtc ho9ZCUgqBVV4BjedgjbJ9+WeUdmZ9YV1PSJt6e9tQXLVnqb16Td5hH4IrVveOG1zUxHf +TJEbMIlJ95s9wsa2qK7lUHwSsyb3sssU/HKuZfZWnCE+bx9fvqT7vaCblsDLrxuiNCU 80lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109955; x=1726714755; h=subject:date:from:to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wssfUvhyRjIM5BP83GJrAm9x0RXTtZGMa0VtBsQ7hyY=; b=RzjE0zylle2O20A7whBCqTGKJKxaJlmkwAEbcjWAOJ6ucIf4olbPMHQ5btY9SN83ak CWO1ZP3iLFXHpJubIkprCn3xYS6z8eActZ4/NH+1bj00Rjosqm0Z+I88Vk5oWqm6zVRs fiPlWf/uSpZM1e6aMTH/WRXj7zDHOuiTHN2cwUiD4BNKWq5y4MMdKwwFLYc7rvWnvYPe 7ABrVRcaENWCXOoxw2Fv1qMq1iIto4R85wncqzZ51CRLfaGLtXsdurutVQq7ifSn5+26 aS9XUazcZphQ6zYYjoNsQ5uSIgWxQAnSJG/IddljjGEDuHv/0zGNpjUC79lTwybW5oob 6d9Q== X-Gm-Message-State: AOJu0YwVxMLlpAU+fUkYss+PxSPppYrB8apbD6knEGSGk+H10K0T4kkL 2+URZ8CYijv6aMpw4JIzyBSi7mlhMxAwku0n0rhwm/N+e671l9DWCS7Njg== X-Received: by 2002:a05:6000:459d:b0:367:980a:6af with SMTP id ffacd0b85a97d-378c2d5fa7cmr569011f8f.59.1726109954719; Wed, 11 Sep 2024 19:59:14 -0700 (PDT) Received: from localhost (p200300cccf026100499a02dfdfb9f5bd.dip0.t-ipconnect.de. [2003:cc:cf02:6100:499a:2df:dfb9:f5bd]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649b88sm13032689f8f.6.2024.09.11.19.59.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Sep 2024 19:59:14 -0700 (PDT) Message-Id: To: From: "Marvin Scholz" Date: Thu, 12 Sep 2024 04:52:43 +0200 Subject: [FFmpeg-devel] [PATCH 1/2] avdevice/decklink_dec: fix leak on error X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: HCANTM3hiYKH In the early return when both draw_bars and signal_loss_action options are used, the context allocated previously was not properly freed. Introduced in 9bcb86b0fa58f1a5a2a8613065349e26abadb329 Fixes CID1619296 --- libavdevice/decklink_dec.cpp | 1 + 1 file changed, 1 insertion(+) base-commit: 2e91532ead860651c135bdedd96b6112ff715529 diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 54d698bc12a..9a817daf187 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -1096,10 +1096,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ctx->signal_loss_action = SIGNAL_LOSS_NONE; av_log(avctx, AV_LOG_WARNING, "Setting signal_loss_action to none because draw_bars is false\n"); } if (!ctx->draw_bars && ctx->signal_loss_action != SIGNAL_LOSS_NONE) { av_log(avctx, AV_LOG_ERROR, "options draw_bars and signal_loss_action are mutually exclusive\n"); + av_freep(&ctx); return AVERROR(EINVAL); } ctx->audio_depth = cctx->audio_depth; if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < FF_ARRAY_ELEMS(decklink_raw_format_map)) ctx->raw_format = decklink_raw_format_map[cctx->raw_format]; From patchwork Thu Sep 12 02:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51530 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp667207vqi; Wed, 11 Sep 2024 19:59:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/kGGsQleLKVT+be5zQRvqcID1k0H9YQJKPTioNFYyWE2EbfX9CRdPS4FX7gtsLJ19CsHmRXHDOsoZchwvVGVF@gmail.com X-Google-Smtp-Source: AGHT+IHb7cAlxmMm/Bvq7OY+CCcZjtPukmOMVYSTB5O8JcgI7/9hwsc4a3A4zx/AweuhqntsttEQ X-Received: by 2002:a05:6402:84d:b0:5c2:609d:397e with SMTP id 4fb4d7f45d1cf-5c413e1ecf5mr957439a12.15.1726109975569; Wed, 11 Sep 2024 19:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726109975; cv=none; d=google.com; s=arc-20240605; b=WFq4c1N+HDrmD4q1yJB/YiVhvs1bKI2g9yDJ0/a4TlQgNo6kUv7+Jwu67GmoHjtoch RF4oL39EeAw9BFHwoCXHei2VzBakjBrDqiPu0gZxaCjRFZL2D8ZaHfcxGadLaxQARhYH TKfMgJzyiIFA9adsBRC8eIMp+gW8aAZtpenUPHyN6zI+Dqfgo/Wo9aNf05YcKnydPxsw KxYQBf1o0Tq48U8IXWFRM5NVcU4PEm+WZeyJNpzW5vVr9M2s/73cWQUiqCvMQXRnbqqu lbE+37Pjt7opElElCIEN7RLnTIe8wcLteWjJFkpgPTNPOb1kYu3nvDvJYoPs7AXND01Z YDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:date:from:to:message-id:in-reply-to :dkim-signature:delivered-to; bh=lADiA3U4uFoDaWD/3uTAhWF9GIIs7oXIvSqNH5hjajM=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=dmL19wvwL5Nrd2dJt97415KSjAPPGi9PQ9ZvBaS9FO4XAFDoa3Hh9MRSDul1Gn3DZB n5B6s1scCy7EmLU3jtNM9r9CvhFQL2KhTL+95BE/0bC2c1yadmy8p13uaKSJBK3IJ7Vi xCHGVCm+vkmaOrHVQmmLNwnEsDRkNX5ssBqImMQ42sXP4EpGuCFCrtoye/PgBh8J3Xs8 F5qbfYr9BXnogEtJkozElbKG2GoDDqpFM7AdMxWrNR0qv39wuHIGFseDpXVSdleoFJaC KZq5rV3cAlMl9D7K/wuq7dKnEZfMGOV9+RaxijbA+E6SEZrxtWMSaicgNby422jmJkxv kr2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=inFFNa3G; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c3ebd98c8asi8199419a12.355.2024.09.11.19.59.35; Wed, 11 Sep 2024 19:59:35 -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=@gmail.com header.s=20230601 header.b=inFFNa3G; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F9C768DD00; Thu, 12 Sep 2024 05:59:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7426168D787 for ; Thu, 12 Sep 2024 05:59:16 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42cc8782869so3858245e9.2 for ; Wed, 11 Sep 2024 19:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726109956; x=1726714756; darn=ffmpeg.org; h=subject:date:from:to:message-id:in-reply-to:from:to:cc:subject:date :message-id:reply-to; bh=AFNLl37VOGDymeHpMqhnxQf4Ovq8b0CH/cPI041oE/k=; b=inFFNa3GJcNi8lxP/052ZAxT9dR5Qovw/Vxy6xpHpRtzDa1r+xR9zNe79JmsnF2u2/ Cpo4oP/5RM9FM3ZttyTxADQZy9N5qj+JeRxuDFbUhy/lId7tFDjCujIJIFy/8W3/Jo6B InCHBguZmzt2Nk7QeBYER51n08Z849958tAMeZqN9FcsGrtJwAxwO0uIr7BEbnaD79ce oEA1Oh76uWg/cFaLjO0t2et9y7Q2b3ycra3FmhbebfegOQl3WuScHsNr2BWjS09sWi4n u8ggiaz9zMV9gr/xlpwFVahPq/FcQDDnAWAIUa3rfU9sl27U3cz0ak/5lobGjqWxN+Q7 9mlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726109956; x=1726714756; h=subject:date:from:to:message-id:in-reply-to:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AFNLl37VOGDymeHpMqhnxQf4Ovq8b0CH/cPI041oE/k=; b=TXJx5E6ayn4ye6wwDh+VaOaASe2j5BCYt/l6B1KfMUfTYE98h4PdZkmjOYPMl2ukTB lepR0AY2DqZbLFE4v6Nf75hlmSSzJTAKu59t3q2Fh9VjgmD9wdzH3eOc8dkKaGre2tbe frPhYp2FSeADe8f4XYCmdAwpKhqBVUoVM9WT3Pvzm2wFinTawC17+1mvTk/b1iO+eRAv 8LoJw6hk69IRGyMjRHw1DMmjanbYmXuUGFHAbejKNVxPLfi9mI7SWmrnifpmWzDsNKQY aWsXR52WC3MgRRcfxCasJIQMok815O1yZy71mLwaTRoA78mCKslROC2kLiy2yW4qCS1/ 7s0A== X-Gm-Message-State: AOJu0YzdzT4JnD2FGH6wTYtjL4jvGlZJdEFxXehDbFY4Y5yCC2dgeW+H WGZ29/qUoKimbMdWsgXMvS5tbv72K5xFk9/5MRpk8ULFSuiBVUpWtps/IA== X-Received: by 2002:a05:600c:1914:b0:42c:b95c:65ba with SMTP id 5b1f17b1804b1-42cdb511f40mr9627995e9.6.1726109955603; Wed, 11 Sep 2024 19:59:15 -0700 (PDT) Received: from localhost (p200300cccf026100499a02dfdfb9f5bd.dip0.t-ipconnect.de. [2003:cc:cf02:6100:499a:2df:dfb9:f5bd]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649b88sm13032689f8f.6.2024.09.11.19.59.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Sep 2024 19:59:15 -0700 (PDT) In-Reply-To: Message-Id: To: From: "Marvin Scholz" Date: Thu, 12 Sep 2024 04:58:38 +0200 Subject: [FFmpeg-devel] [PATCH 2/2] avdevice/decklink_dec: fix leaks on error X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ABJ0rD89F0PW In case of errors in this function, the allocated context was not properly freed in several cases. --- libavdevice/decklink_dec.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 9a817daf187..418701e4e0c 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -1112,32 +1112,35 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) case 8: case 16: break; default: av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n"); - return AVERROR(EINVAL); + ret = AVERROR(EINVAL); + goto error; } /* Check audio bit depth option for valid values: 16 or 32 */ switch (cctx->audio_depth) { case 16: case 32: break; default: av_log(avctx, AV_LOG_ERROR, "Value for audio bit depth option must be either 16 or 32\n"); - return AVERROR(EINVAL); + ret = AVERROR(EINVAL); + goto error; } /* List available devices. */ if (ctx->list_devices) { ff_decklink_list_devices_legacy(avctx, 1, 0); - return AVERROR_EXIT; + ret = AVERROR_EXIT; + goto error; } ret = ff_decklink_init_device(avctx, avctx->url); if (ret < 0) - return ret; + goto error; /* Get input device. */ if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n", avctx->url); @@ -1334,10 +1337,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) return 0; error: ff_decklink_cleanup(avctx); + av_freep(&cctx->ctx); return ret; } int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt) {