pw_kvs: Fix null access in FindSectorToGarbageCollect()
Fix a null access when logging find results in a full KVS that fails to
find a sector to garbage collect.
Change-Id: I84595d1788c393949cdbb34012d9ff1d447b1753
diff --git a/pw_kvs/key_value_store.cc b/pw_kvs/key_value_store.cc
index 9949b88..b9beed2 100644
--- a/pw_kvs/key_value_store.cc
+++ b/pw_kvs/key_value_store.cc
@@ -681,9 +681,13 @@
}
}
- DBG("Found sector %zu to Garbage Collect, %zu recoverable bytes",
- SectorIndex(sector_candidate),
- RecoverableBytes(*sector_candidate));
+ if (sector_candidate != nullptr) {
+ DBG("Found sector %zu to Garbage Collect, %zu recoverable bytes",
+ SectorIndex(sector_candidate),
+ RecoverableBytes(*sector_candidate));
+ } else {
+ DBG("Unable to find sector to garbage collect!");
+ }
return sector_candidate;
}