diff --git a/services/distributeddataservice/app/src/backup_handler.cpp b/services/distributeddataservice/app/src/backup_handler.cpp index ac0eae47cf4690f10e7e8179bdb21067a16bb936..1ef5a8596ab937a73f43e54f213d8a985db6b4ee 100644 --- a/services/distributeddataservice/app/src/backup_handler.cpp +++ b/services/distributeddataservice/app/src/backup_handler.cpp @@ -97,8 +97,11 @@ void BackupHandler::SingleKvStoreBackup(const MetaData &metaData) dbOption.createDirByStoreIdOnly = true; dbOption.secOption = KvStoreAppManager::ConvertSecurity(metaData.kvStoreMetaData.securityLevel); - auto *delegateMgr = new DistributedDB::KvStoreDelegateManager(metaData.kvStoreMetaData.appId, + auto *delegateMgr = new(std::nothrow) DistributedDB::KvStoreDelegateManager(metaData.kvStoreMetaData.appId, AccountDelegate::GetInstance()->GetCurrentAccountId(metaData.kvStoreMetaData.bundleName)); + if (delegateMgr == nullptr) { + return; + } std::string appDataStoragePath = KvStoreAppManager::GetDataStoragePath(metaData.kvStoreMetaData.deviceAccountId, metaData.kvStoreMetaData.bundleName, backupPara.pathType); diff --git a/services/distributeddataservice/app/src/query_helper.cpp b/services/distributeddataservice/app/src/query_helper.cpp index cb56bf8a5349bb24e346dcdc34442482d41760cd..c11c417e93c45b418d7147a2170de8be6f487158 100644 --- a/services/distributeddataservice/app/src/query_helper.cpp +++ b/services/distributeddataservice/app/src/query_helper.cpp @@ -36,7 +36,7 @@ DistributedDB::Query QueryHelper::StringToDbQuery(const std::string &query, bool { ZLOGI("query string length:%{public}zu", query.length()); DistributedDB::Query dbQuery = DistributedDB::Query::Select(); - if (query.size() == 0) { + if (query.empty()) { ZLOGI("Query string is empty."); isSuccess = true; return dbQuery; diff --git a/services/distributeddataservice/framework/include/serializable/serializable.h b/services/distributeddataservice/framework/include/serializable/serializable.h index 6387e19aadd19639cbdd28f54b3f9d83d4c8c6e0..71fe7adfe3f44644e1a3c26cb21b7590dbf27667 100644 --- a/services/distributeddataservice/framework/include/serializable/serializable.h +++ b/services/distributeddataservice/framework/include/serializable/serializable.h @@ -74,7 +74,10 @@ protected: if (subNode.is_null()) { return false; } - value = new T(); + value = new(std::nothrow) T(); + if (value == nullptr) { + return false; + } bool result = GetValue(subNode, "", *value); if (!result) { delete value;