From f58c6c3880ad5ee5ba04cf6642e66ed453de5ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Fri, 13 Sep 2024 00:01:26 +0100 Subject: [PATCH] fix: cover image memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 鲁树人 --- src/ncmcrypt.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ncmcrypt.cpp b/src/ncmcrypt.cpp index e2c7c73..d36fd1d 100644 --- a/src/ncmcrypt.cpp +++ b/src/ncmcrypt.cpp @@ -403,10 +403,8 @@ NeteaseCrypt::NeteaseCrypt(std::string const &path) if (n > 0) { - char *imageData = (char *)malloc(n); - read(imageData, n); - - mImageData = std::string(imageData, n); + mImageData = std::string(n, '\0'); + read(&mImageData[0], n); } else {