From patchwork Mon Apr 15 13:23:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 12742 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 35128447644 for ; Mon, 15 Apr 2019 08:23:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1249A68A3AF; Mon, 15 Apr 2019 08:23:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D2696898C4 for ; Mon, 15 Apr 2019 08:23:24 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Apr 2019 22:23:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,352,1549958400"; d="scan'208";a="291583194" Received: from media_lj_kbl.sh.intel.com ([10.239.13.101]) by orsmga004.jf.intel.com with ESMTP; 14 Apr 2019 22:23:21 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Apr 2019 21:23:18 +0800 Message-Id: <20190415132318.19975-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak for enc_ctrl.Payload 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" frame->enc_ctrl.Payload is malloced in get_free_frame, directly memset the whole structure of enc_ctrl to zero will cause the memory leak for enc_ctrl.Payload. frame->enc_ctrl as a structure will be malloc and init to zero by calling frame = av_mallocz(sizeof(*frame)), so the memset is redundant and can be removed. Can be reproduced by #7830. Signed-off-by: Linjie Fu --- libavcodec/qsvenc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 5aa020d47b..19953bd4ea 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1254,7 +1254,6 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, if (qsv_frame) { surf = &qsv_frame->surface; enc_ctrl = &qsv_frame->enc_ctrl; - memset(enc_ctrl, 0, sizeof(mfxEncodeCtrl)); if (frame->pict_type == AV_PICTURE_TYPE_I) { enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;