Correctly check validity for type during setType.

This commit is contained in:
JoelKatz
2012-09-29 01:30:17 -07:00
parent 3e305871c3
commit 98655aed4d
4 changed files with 46 additions and 37 deletions

View File

@@ -14,7 +14,8 @@ SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint
if (mFormat == NULL)
throw std::runtime_error("invalid ledger entry type");
mType = mFormat->t_type;
setType(mFormat->elements);
if (!setType(mFormat->elements))
throw std::runtime_error("ledger entry not valid for type");
}
SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256& index)
@@ -28,7 +29,8 @@ SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256&
if (mFormat == NULL)
throw std::runtime_error("invalid ledger entry type");
mType = mFormat->t_type;
setType(mFormat->elements);
if (!setType(mFormat->elements))
throw std::runtime_error("ledger entry not valid for type");
}
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : STObject(sfLedgerEntry), mType(type)