forked from lix-project/lix
Value::mkString: Avoid crash from null string_view
This commit is contained in:
parent
c28e2b1b29
commit
1b978596b5
|
@ -805,8 +805,14 @@ 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)
|
||||||
{
|
{
|
||||||
|
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()));
|
mkString(dupStringWithLen(s.data(), s.size()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void copyContextToValue(Value & v, const PathSet & context)
|
static void copyContextToValue(Value & v, const PathSet & context)
|
||||||
|
|
Loading…
Reference in a new issue