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) void EvalState::mkPos(Value & v, Pos * pos)
{ {
if (pos) { if (pos && pos->file.set()) {
mkAttrs(v, 3); mkAttrs(v, 3);
mkString(*allocAttr(v, sFile), pos->file); mkString(*allocAttr(v, sFile), pos->file);
mkInt(*allocAttr(v, sLine), pos->line); mkInt(*allocAttr(v, sLine), pos->line);

View file

@ -0,0 +1 @@
null

View file

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