libexpr: Make unsafeGetAttrPos not crash on noPos

Currently e.g. `builtins.unsafeGetAttrPos "abort" builtins` will
eventually segfault because pos->file is an unset Symbol.

Found by afl-fuzz.
This commit is contained in:
Tuomas Tynkkynen 2018-04-03 15:27:17 +03:00
parent 3fbaa230a2
commit af86132e1a
3 changed files with 3 additions and 1 deletions

View File

@ -628,7 +628,7 @@ void EvalState::mkThunk_(Value & v, Expr * expr)
void EvalState::mkPos(Value & v, Pos * pos)
{
if (pos) {
if (pos && pos->file.set()) {
mkAttrs(v, 3);
mkString(*allocAttr(v, sFile), pos->file);
mkInt(*allocAttr(v, sLine), pos->line);

View File

@ -0,0 +1 @@
null

View File

@ -0,0 +1 @@
builtins.unsafeGetAttrPos "abort" builtins