Dereference of null pointer #5353 (#5376)

add an assert to make sure that `key_field` is not a null pointer.
This commit is contained in:
360 CodeSafe
2019-05-31 08:50:21 +08:00
committed by Wouter van Oortmerssen
parent 51dd733ba4
commit 3a88e1031b

View File

@@ -1450,6 +1450,7 @@ class GeneralGenerator : public BaseGenerator {
// Only generate key compare function for table,
// because `key_field` is not set for struct
if (struct_def.has_key && !struct_def.fixed) {
FLATBUFFERS_ASSERT(key_field);
if (lang_.language == IDLOptions::kJava) {
code += "\n @Override\n protected int keysCompare(";
code += "Integer o1, Integer o2, ByteBuffer _bb) {";