[CVRecord] Don't assume that the record has two bytes of data in it

llvm-svn: 271171
This commit is contained in:
David Majnemer 2016-05-29 06:18:04 +00:00
parent 61f1caa555
commit 21de7b99a0
1 changed files with 2 additions and 0 deletions

View File

@ -34,6 +34,8 @@ template <typename Kind> struct VarStreamArrayExtractor<CVRecord<Kind>> {
if (auto EC = Reader.readObject(Prefix)) if (auto EC = Reader.readObject(Prefix))
return EC; return EC;
Item.Length = Prefix->RecordLen; Item.Length = Prefix->RecordLen;
if (Item.Length < 2)
return make_error<CodeViewError>(cv_error_code::corrupt_record);
Item.Type = static_cast<Kind>(uint16_t(Prefix->RecordKind)); Item.Type = static_cast<Kind>(uint16_t(Prefix->RecordKind));
if (auto EC = Reader.readBytes(Item.Data, Item.Length - 2)) if (auto EC = Reader.readBytes(Item.Data, Item.Length - 2))
return EC; return EC;