Fix segfault in input framework when reading unset fields

Unset fields could trigger unexpected null pointers in the input
manager. This also adds a warning such fields come up.
This commit is contained in:
Christian Kreibich 2021-06-16 15:30:56 -07:00
parent 38d4907903
commit ef08605877

View file

@ -1073,7 +1073,21 @@ Val* Manager::ValueToIndexVal(const Stream* i, int num_fields, const RecordType
} }
else else
{ {
// Bail early here if we already have an error. ValueToVal() won't do
// anything in that case, and by checking first we know that if
// ValueToVal() returns nullptr, there is a new problem.
if ( have_error )
break;
auto v = ValueToVal(i, vals[position], type->GetFieldType(j).get(), have_error); auto v = ValueToVal(i, vals[position], type->GetFieldType(j).get(), have_error);
if ( ! v )
{
// Since we're building a (list) value for indexing into
// a table, it is for sure an error to miss a value.
Warning(i, "Skipping input with missing non-optional value");
have_error = true;
}
if ( have_error ) if ( have_error )
break; break;