[ledger] fix a btree decoding crash found by fuzzing

LE-654 #done

Test: ledger_fuzztests don't crash
Change-Id: I1d472ca056cbbe2e1ea0b8a56bce63585c74e007
diff --git a/bin/ledger/storage/impl/btree/encoding.cc b/bin/ledger/storage/impl/btree/encoding.cc
index dfc9997..b5a1855 100644
--- a/bin/ledger/storage/impl/btree/encoding.cc
+++ b/bin/ledger/storage/impl/btree/encoding.cc
@@ -25,6 +25,11 @@
   }
 }
 
+bool IsKeyPriorityStorageValid(KeyPriorityStorage priority_storage) {
+  return priority_storage == KeyPriorityStorage_EAGER ||
+    priority_storage == KeyPriorityStorage_LAZY;
+}
+
 KeyPriorityStorage ToKeyPriorityStorage(KeyPriority priority) {
   switch (priority) {
     case KeyPriority::EAGER:
@@ -36,7 +41,8 @@
 
 bool IsTreeNodeEntryValid(const EntryStorage* entry) {
   return entry && entry->key() &&
-         IsObjectIdentifierStorageValid(entry->object_id());
+         IsObjectIdentifierStorageValid(entry->object_id()) &&
+         IsKeyPriorityStorageValid(entry->priority());
 }
 
 Entry ToEntry(const EntryStorage* entry_storage) {