From patchwork Wed Mar 10 21:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26323 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 3FCFF44B799 for ; Wed, 10 Mar 2021 23:55:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CD2E68AB3B; Wed, 10 Mar 2021 23:55:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8DB8168AB33 for ; Wed, 10 Mar 2021 23:55:37 +0200 (EET) Received: by mail-ed1-f44.google.com with SMTP id l12so71738edt.3 for ; Wed, 10 Mar 2021 13:55:37 -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:reply-to :mime-version:content-transfer-encoding; bh=FyOFa6JWM36A+DsNA3lvlpyNwyYcw0lkEHYUirPmiUA=; b=YDbN3MdiZt7lL/YR1RxspOl6hD70gBToORJ9nwuYJWjbirRsPbRVyIzUHPhtO3Vq8n 4THmR8l/bPBooMw+5m7aTdUf9GBCAleTnZR5fcPG8256voHGSB1XOco9xDZExFtKeD1u ZgPLLZ3bvwCyXrn2J3Hpdmc7N8EpH1/uoCbh3FZdlyikGmXiqOxdvqmMwUHVRxfaiYp4 Yn4L6rjH/LkX6TiJIN6T/7MemAVU4gV1t/mZ6lhh5GW96030VKvjuDaYlwkozjIAKRsk pCVcCQAUBCpsNAIWxnlrSP9lgAeX1vubMYj/b9kUiPUQVIMHBtw2E/Bo2wPsSQa+sKN0 co5Q== 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:reply-to:mime-version:content-transfer-encoding; bh=FyOFa6JWM36A+DsNA3lvlpyNwyYcw0lkEHYUirPmiUA=; b=j8lS2dKVT28Vc6EOlr0N40r5GqYFfqx80LZPrNJJtb5sMJttJs3otZYtPg00vjAhhr +5hWIaJi/GAkQWTFI61bwxKijFnZCN+fOopas50yH+VnplJ9gQDyx7R7WHXp1Fu4Z4Zw 8w1F7HpJfLQRv8cDh2Q3Do9e33Skw7DWch8bVlrOY/BFCVB6F7hSZIfUA4t535TzOD/3 vqB/Q2MqZ5gCStkzmmzIUV6fcqkHEjM7W42h7rjHRWzpqjsccnZuUWlJ5WAtV1uY4mvG w+G2r0V8llg4DtQAh00oz1LKQaBd0K+IKFnf6B9ElONEa8zQo6kMaGkJiaojIKbbfABi /QXg== X-Gm-Message-State: AOAM530mA+Yu3XRdzrPtyDokDlhFLmLWWl3vcnZ5VFMcyrCGEsbkjsAG jC6Ky97aVPIUS4IEC/Ue31btcqIyAew= X-Google-Smtp-Source: ABdhPJw9fMFFbJ2ZV3wnb37eAltYwrKbos7OOEELGhw+sdx+GC1THS2A37Psu3diQVj/HiDwzC4WYg== X-Received: by 2002:a05:6402:6cb:: with SMTP id n11mr5632651edy.198.1615413336876; Wed, 10 Mar 2021 13:55:36 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id m10sm351993ejx.10.2021.03.10.13.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:55:36 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 22:54:37 +0100 Message-Id: <20210310215446.1396386-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210310010601.1142819-1-andreas.rheinhardt@gmail.com> References: <20210310010601.1142819-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/23] dnn/dnn_backend_native_layer_conv2d: Fix memleak on realloc failure 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 --- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index b5c2c394ef..2b83896da9 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -197,6 +197,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera int width = operands[input_operand_indexes[0]].dims[2]; int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0; DnnOperand *output_operand = &operands[output_operand_index]; + void *tmp; output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0]; output_operand->dims[1] = height - pad_size * 2; @@ -208,11 +209,12 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); return DNN_ERROR; } - output_operand->data = av_realloc(output_operand->data, output_operand->length); - if (!output_operand->data) { + tmp = av_realloc(output_operand->data, output_operand->length); + if (!tmp) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); return DNN_ERROR; } + output_operand->data = tmp; thread_common_param.output_data = output_operand->data; thread_common_param.operands = operands; thread_common_param.input_operand_indexes = input_operand_indexes;