[TS]: builder, Fix requiredField(). Verity that the field is present in the vtable (#7739) (#7752)

* [TS]: Fix vtable creation for consecutive required fileds (#7739)

* handle feedback

* comment the schema

* comment change in builder.ts

* [TS]: builder, Fix requiredField()

Verifty that the field is present in the vtable.

* restore monsterdata binary file

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
José Luis Millán
2023-01-10 19:43:17 +01:00
committed by GitHub
parent b23493a7d2
commit b17d59b18c
8 changed files with 163 additions and 2 deletions

View File

@@ -458,7 +458,8 @@ export class Builder {
requiredField(table: Offset, field: number): void {
const table_start = this.bb.capacity() - table;
const vtable_start = table_start - this.bb.readInt32(table_start);
const ok = this.bb.readInt16(vtable_start + field) != 0;
const ok = field < this.bb.readInt16(vtable_start) &&
this.bb.readInt16(vtable_start + field) != 0;
// If this fails, the caller will show what field needs to be set.
if (!ok) {