From 91b804a68383239eec3332a778f8c8d4de20f656 Mon Sep 17 00:00:00 2001 From: wuyunxun Date: Tue, 15 Jul 2025 17:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuyunxun Change-Id: I2cc242a282ac2450f50ffa4f84dd065cba56861b --- .../native/backup_ext/src/ext_backup_ani.cpp | 14 ++++++++++++-- .../kits/ani/file_share/src/ani_file_share.cpp | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frameworks/native/backup_ext/src/ext_backup_ani.cpp b/frameworks/native/backup_ext/src/ext_backup_ani.cpp index ffb67e5a4..bc3d52d8e 100644 --- a/frameworks/native/backup_ext/src/ext_backup_ani.cpp +++ b/frameworks/native/backup_ext/src/ext_backup_ani.cpp @@ -76,7 +76,12 @@ void ExtBackupAni::Init(const std::shared_ptr &r ErrCode ExtBackupAni::CallEtsOnBackup() { ani_vm *vm = nullptr; - if (ANI_OK != stsRuntime_.GetAniEnv()->GetVM(&vm)) { + auto aniEnv = stsRuntime_.GetAniEnv(); + if (aniEnv == nullptr) { + HILOGE("aniEnv null"); + return EINVAL; + } + if (ANI_OK != aniEnv->GetVM(&vm)) { return EINVAL; } ani_env *env = nullptr; @@ -103,7 +108,12 @@ ErrCode ExtBackupAni::CallEtsOnBackup() ErrCode ExtBackupAni::CallEtsOnRestore() { ani_vm *vm = nullptr; - if (ANI_OK != stsRuntime_.GetAniEnv()->GetVM(&vm)) { + auto aniEnv = stsRuntime_.GetAniEnv(); + if (aniEnv == nullptr) { + HILOGE("aniEnv null"); + return EINVAL; + } + if (ANI_OK != aniEnv->GetVM(&vm)) { return EINVAL; } ani_env *env = nullptr; diff --git a/interfaces/kits/ani/file_share/src/ani_file_share.cpp b/interfaces/kits/ani/file_share/src/ani_file_share.cpp index 0c20eb40d..614aabd4c 100644 --- a/interfaces/kits/ani/file_share/src/ani_file_share.cpp +++ b/interfaces/kits/ani/file_share/src/ani_file_share.cpp @@ -199,7 +199,6 @@ static int InsertByDatashare(const DataShareValuesBucket &valuesBucket, bool isA dataShareHelper = DataShare::DataShareHelper::Creator(remote->AsObject(), MEDIALIBRARY_DATA_URI); if (!dataShareHelper) { LOGE("%{public}s: connect to datashare failed!", __func__); - delete remote; return ret; } string uriStr = MEDIA_GRANT_URI_PERMISSION; -- Gitee