forked from OSchip/llvm-project
In StringLiteral::setString make sure that we copy the number of
bytes of the buffer and not the size of the string, otherwise we may overwrite the buffer if there is a mismatch between the size of the string and the CharByteWidth, and assertions are disabled. The bug where this could occur was fixed in r163931. Related to rdar://12069503 llvm-svn: 163939
This commit is contained in:
parent
94b092461d
commit
617108990d
|
@ -784,19 +784,19 @@ void StringLiteral::setString(ASTContext &C, StringRef Str,
|
||||||
switch(CharByteWidth) {
|
switch(CharByteWidth) {
|
||||||
case 1: {
|
case 1: {
|
||||||
char *AStrData = new (C) char[Length];
|
char *AStrData = new (C) char[Length];
|
||||||
std::memcpy(AStrData,Str.data(),Str.size());
|
std::memcpy(AStrData,Str.data(),Length*sizeof(*AStrData));
|
||||||
StrData.asChar = AStrData;
|
StrData.asChar = AStrData;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
uint16_t *AStrData = new (C) uint16_t[Length];
|
uint16_t *AStrData = new (C) uint16_t[Length];
|
||||||
std::memcpy(AStrData,Str.data(),Str.size());
|
std::memcpy(AStrData,Str.data(),Length*sizeof(*AStrData));
|
||||||
StrData.asUInt16 = AStrData;
|
StrData.asUInt16 = AStrData;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
uint32_t *AStrData = new (C) uint32_t[Length];
|
uint32_t *AStrData = new (C) uint32_t[Length];
|
||||||
std::memcpy(AStrData,Str.data(),Str.size());
|
std::memcpy(AStrData,Str.data(),Length*sizeof(*AStrData));
|
||||||
StrData.asUInt32 = AStrData;
|
StrData.asUInt32 = AStrData;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue