Check the validity of the buffer before parsing the model
If the buffer does not point to a well defined flatbuffer the parsing
segfaults.
Change-Id: Icb8dfef37dc28b2b7a22c6d3804851be8198aa9d
diff --git a/applications/inference_process/src/inference_process.cpp b/applications/inference_process/src/inference_process.cpp
index 29254c7..e96d601 100644
--- a/applications/inference_process/src/inference_process.cpp
+++ b/applications/inference_process/src/inference_process.cpp
@@ -119,11 +119,9 @@
RegisterDebugLogCallback(tfluDebugLog);
// Get model handle and verify that the version is correct
- const tflite::Model *model = ::tflite::GetModel(job.networkModel.data);
- if (model->version() != TFLITE_SCHEMA_VERSION) {
- LOG_ERR("Model schema version unsupported: version=%" PRIu32 ", supported=%d.",
- model->version(),
- TFLITE_SCHEMA_VERSION);
+ const tflite::Model *model = parser.getModel(job.networkModel.data, job.networkModel.size);
+ if (model == nullptr) {
+ LOG_ERR("Invalid model");
return true;
}