diff options
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp index 7b972a1a277..6e647c4b976 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp @@ -24,7 +24,7 @@ Error DebugStringTableSubsectionRef::initialize(BinaryStreamRef Contents) { return Error::success(); } Error DebugStringTableSubsectionRef::initialize(BinaryStreamReader &Reader) { - return Reader.readStreamRef(Stream, Reader.bytesRemaining()); + return Reader.readStreamRef(Stream); } Expected<StringRef> @@ -55,20 +55,19 @@ uint32_t DebugStringTableSubsection::calculateSerializedSize() const { } Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const { - assert(Writer.bytesRemaining() == StringSize); - uint32_t MaxOffset = 1; + uint32_t Begin = Writer.getOffset(); + uint32_t End = Begin + StringSize; for (auto &Pair : Strings) { StringRef S = Pair.getKey(); - uint32_t Offset = Pair.getValue(); + uint32_t Offset = Begin + Pair.getValue(); Writer.setOffset(Offset); if (auto EC = Writer.writeCString(S)) return EC; - MaxOffset = std::max<uint32_t>(MaxOffset, Offset + S.size() + 1); + assert(Writer.getOffset() <= End); } - Writer.setOffset(MaxOffset); - assert(Writer.bytesRemaining() == 0); + Writer.setOffset(End); return Error::success(); } |