diff --git a/interfaces/kits/js/backup/session_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_backup_n_exporter.cpp index c7e09daa30ee819895bea63ffa427aa811e85e82..a2850d5050d4a904b89dd85239075826789b0cb4 100644 --- a/interfaces/kits/js/backup/session_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_backup_n_exporter.cpp @@ -308,7 +308,7 @@ static void OnProcess(weak_ptr pCallbacks, const BundleName na static bool SetSessionBackupEntity(napi_env env, NFuncArg &funcArg, std::unique_ptr backupEntity) { auto finalize = [](napi_env env, void *data, void *hint) { - BackupEntity *entity = static_cast(data); + std::unique_ptr entity = std::unique_ptr(static_cast(data)); if (entity == nullptr) { HILOGE("Entity is nullptr"); return; diff --git a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp index e50e81c14afa11c1727504dcbb8f8cd478b8b6a4..f1feabd90e1d01269518e645dfefc7aac6f626e4 100644 --- a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp @@ -312,7 +312,7 @@ static void OnProcess(weak_ptr pCallbacks, const BundleName na static bool SetIncrementalBackupEntity(napi_env env, NFuncArg &funcArg, std::unique_ptr backupEntity) { auto finalize = [](napi_env env, void *data, void *hint) { - BackupEntity *entity = static_cast(data); + std::unique_ptr entity = std::unique_ptr(static_cast(data)); if (entity == nullptr) { HILOGE("Entity is nullptr"); return; diff --git a/interfaces/kits/js/backup/session_restore_n_exporter.cpp b/interfaces/kits/js/backup/session_restore_n_exporter.cpp index 21bf2996b32c7ddc786f51666c6e5716445e5bf4..405ecf334e536bb28768a5ed6527d58a6042749e 100644 --- a/interfaces/kits/js/backup/session_restore_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_restore_n_exporter.cpp @@ -423,7 +423,7 @@ static bool VerifyNarg(napi_env env, NVal &callbacks) static bool SetSessionRestoreEntity(napi_env env, NFuncArg &funcArg, std::unique_ptr restoreEntity) { auto finalize = [](napi_env env, void *data, void *hint) { - RestoreEntity *entity = static_cast(data); + std::unique_ptr entity = std::unique_ptr(static_cast(data)); if (entity == nullptr) { HILOGE("Entity is nullptr"); return;