Skip to content

Commit 4588525

Browse files
committed
CoverageMappingReader/Writer: MCDCConditionID shouldn't be zero
1 parent 0a600c3 commit 4588525

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ Error RawCoverageMappingReader::readMappingRegionsSubArray(
308308
return Err;
309309
if (auto Err = readIntMax(FID, std::numeric_limits<unsigned>::max()))
310310
return Err;
311+
if (ID == 0)
312+
return make_error<CoverageMapError>(
313+
coveragemap_error::malformed,
314+
"MCDCConditionID shouldn't be zero");
311315
break;
312316
case CounterMappingRegion::MCDCDecisionRegion:
313317
Kind = CounterMappingRegion::MCDCDecisionRegion;

llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
251251
OS);
252252
writeCounter(MinExpressions, Count, OS);
253253
writeCounter(MinExpressions, FalseCount, OS);
254+
assert(I->MCDCParams.ID > 0);
254255
encodeULEB128(unsigned(I->MCDCParams.ID), OS);
255256
encodeULEB128(unsigned(I->MCDCParams.TrueID), OS);
256257
encodeULEB128(unsigned(I->MCDCParams.FalseID), OS);

0 commit comments

Comments
 (0)