mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-10 15:16:28 +00:00
[C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)
This commit fixes handling of default and NULL `key` fields in `Parser::ParseVector` (#5928). The JSON generator updated. It outputs `key` fields even if the `--force-defaults` option is inactive. Additional test cases for `key` added.
This commit is contained in:
@@ -292,7 +292,7 @@ struct JsonPrinter {
|
||||
it != struct_def.fields.vec.end(); ++it) {
|
||||
FieldDef &fd = **it;
|
||||
auto is_present = struct_def.fixed || table->CheckField(fd.value.offset);
|
||||
auto output_anyway = opts.output_default_scalars_in_json &&
|
||||
auto output_anyway = (opts.output_default_scalars_in_json || fd.key) &&
|
||||
IsScalar(fd.value.type.base_type) && !fd.deprecated;
|
||||
if (is_present || output_anyway) {
|
||||
if (fieldout++) { AddComma(); }
|
||||
|
||||
Reference in New Issue
Block a user