Value::mkString: Avoid crash from null string_view
This commit is contained in:
parent
c28e2b1b29
commit
1b978596b5
|
@ -805,7 +805,13 @@ LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, con
|
||||||
|
|
||||||
void Value::mkString(std::string_view s)
|
void Value::mkString(std::string_view s)
|
||||||
{
|
{
|
||||||
mkString(dupStringWithLen(s.data(), s.size()));
|
if (s.size() == 0) {
|
||||||
|
// s.data() may not be valid and we don't need to allocate.
|
||||||
|
mkString("");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mkString(dupStringWithLen(s.data(), s.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue