Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h

Issue 1156103003: Initial implementation of a record-level bitcode fuzzer. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@fuzz
Patch Set: Fix nits. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
diff --git a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
index 39a5009c865ba196a123d3947dfa8c1abf4cf2e0..331c3d181cfaf0886ddbb8ab014a23a4e7350d02 100644
--- a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
+++ b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h
@@ -431,9 +431,9 @@ public:
/// Returns a pointer to the abbreviation currently associated with
/// the abbreviation index. Returns nullptr if no such abbreviation.
const NaClBitCodeAbbrev *getAbbreviation(unsigned Index) const {
- if (Index < naclbitc::FIRST_APPLICATION_ABBREV)
- return nullptr;
- if (Index >= BlockScope.back().AbbreviationIndexLimit)
+ if (Index < naclbitc::FIRST_APPLICATION_ABBREV
+ || BlockScope.empty()
+ || Index >= BlockScope.back().AbbreviationIndexLimit)
return nullptr;
unsigned AbbrevNo = Index - naclbitc::FIRST_APPLICATION_ABBREV;
if (AbbrevNo >= CurAbbrevs.size())
@@ -494,6 +494,7 @@ public:
/// method takes ownership of the specified abbrev.
unsigned EmitAbbrev(NaClBitCodeAbbrev *Abbv) {
assert(Abbv->isValid() && "Can't emit invalid abbreviation!");
+ assert(!BlockScope.empty() && "Can't emit abbreviations outside of blocks");
// Emit the abbreviation as a record.
EncodeAbbrev(Abbv);
CurAbbrevs.push_back(Abbv);

Powered by Google App Engine
This is Rietveld 408576698