Skip to content

Commit ff3d282

Browse files
Fix a crash in DiskCache::Size method (#1550)
The crash happened on a call to Size method on a closed cache. Relates-To: OCMAM-106 Signed-off-by: Mykhailo Kuchma <ext-mykhailo.kuchma@here.com>
1 parent b7e2bcb commit ff3d282

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

olp-cpp-sdk-core/src/cache/DiskCache.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,10 @@ leveldb::Options DiskCache::CreateOpenOptions(const StorageSettings& settings,
541541
}
542542

543543
uint64_t DiskCache::Size() const {
544+
if (!database_) {
545+
OLP_SDK_LOG_ERROR(kLogTag, "Size: Database is not initialized");
546+
return 0;
547+
}
544548
uint64_t result{0u};
545549
leveldb::Range range{"0", "z"};
546550
database_->GetApproximateSizes(&range, 1, &result);

0 commit comments

Comments
 (0)