!2277 元数据管理增加预防空指针维测

Merge pull request !2277 from yanhui/crash
This commit is contained in:
openharmony_ci 2024-09-14 09:37:43 +00:00 committed by Gitee
commit ddfbdd162f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -86,6 +86,10 @@ MetaDataManager::Filter::Filter(const std::string &pattern) : pattern_(pattern)
void MetaObserver::OnChange(const DistributedDB::KvStoreChangedData &data)
{
if (filter_ == nullptr) {
ZLOGE("filter_ is nullptr!");
return;
}
auto values = { &data.GetEntriesInserted(), &data.GetEntriesUpdated(), &data.GetEntriesDeleted() };
int32_t next = MetaDataManager::INSERT;
for (auto value : values) {
@ -117,6 +121,10 @@ void MetaObserver::HandleChanges(int32_t flag, std::vector<std::vector<Type>> &p
if (priData.empty()) {
return;
}
if (filter_ == nullptr) {
ZLOGE("filter_ is nullptr!");
return;
}
for (const auto &priKey : priData) {
if (priKey.empty()) {
continue;