Fix segfault with incomplete connection

Add required HasField check before GetFieldAs call
This commit is contained in:
Luke Cesarz 2021-06-20 07:47:19 -07:00
parent 2de38750fd
commit d29a43fb79
2 changed files with 16 additions and 0 deletions

View file

@ -1202,6 +1202,18 @@ public:
return (*record_val)[field] ? true : false;
}
/**
* Returns true if the given field is in the record, false if
* it's missing.
* @param field The field name to retrieve.
* @return Whether there's a value for the given field name.
*/
bool HasField(const char *field) const
{
int idx = GetType()->AsRecordType()->FieldOffset(field);
return HasField(idx);
}
/**
* Returns the value of a given field index.
* @param field The field index to retrieve.