mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 10:01:42 +00:00
[UB] Guard two calls to memcpy in generated attribute code to handle
null StringRef objects as inputs. Found by UBSan. llvm-svn: 243949
This commit is contained in:
parent
a91ba1260a
commit
38a45cc686
@ -326,7 +326,8 @@ namespace {
|
||||
OS << " " << getLowerName() << "Length = S.size();\n";
|
||||
OS << " this->" << getLowerName() << " = new (C, 1) char ["
|
||||
<< getLowerName() << "Length];\n";
|
||||
OS << " std::memcpy(this->" << getLowerName() << ", S.data(), "
|
||||
OS << " if (!S.empty())\n";
|
||||
OS << " std::memcpy(this->" << getLowerName() << ", S.data(), "
|
||||
<< getLowerName() << "Length);\n";
|
||||
OS << " }";
|
||||
}
|
||||
@ -337,7 +338,8 @@ namespace {
|
||||
OS << "A->get" << getUpperName() << "()";
|
||||
}
|
||||
void writeCtorBody(raw_ostream &OS) const override {
|
||||
OS << " std::memcpy(" << getLowerName() << ", " << getUpperName()
|
||||
OS << " if (!" << getUpperName() << ".empty())\n";
|
||||
OS << " std::memcpy(" << getLowerName() << ", " << getUpperName()
|
||||
<< ".data(), " << getLowerName() << "Length);";
|
||||
}
|
||||
void writeCtorInitializers(raw_ostream &OS) const override {
|
||||
|
Loading…
Reference in New Issue
Block a user