&vectorval[0] is UB when vectorval.size() == 0.

llvm-svn: 149430
This commit is contained in:
Michael J. Spencer 2012-01-31 21:46:41 +00:00
parent 4e45ebb92c
commit 8c36f458fa
1 changed files with 10 additions and 6 deletions

View File

@ -38,12 +38,16 @@ public:
// write the lld::File in native format to the specified stream
void write(llvm::raw_ostream& out) {
out.write((char*)_headerBuffer, _headerBufferSize);
out.write((char*)&_definedAtomIvars[0],
_definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1));
out.write((char*)&_attributes[0],
_attributes.size()*sizeof(NativeAtomAttributesV1));
out.write((char*)&_contentPool[0], _contentPool.size());
out.write(&_stringPool[0], _stringPool.size());
if (!_definedAtomIvars.empty())
out.write((char*)&_definedAtomIvars[0],
_definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1));
if (!_attributes.empty())
out.write((char*)&_attributes[0],
_attributes.size()*sizeof(NativeAtomAttributesV1));
if (!_contentPool.empty())
out.write((char*)&_contentPool[0], _contentPool.size());
if (!_stringPool.empty())
out.write(&_stringPool[0], _stringPool.size());
}
private: