Skip to content

Commit

Permalink
Check for flatbuffer loading failures
Browse files Browse the repository at this point in the history
Will report "Failed to build model from buffer" if it's invalid flatbuffer.

PiperOrigin-RevId: 691554844
  • Loading branch information
yijie-yang authored and copybara-github committed Oct 30, 2024
1 parent c9da2c5 commit c90bc64
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ absl::StatusOr<std::string> ConvertFlatbufferDirectlyToJson(
std::unique_ptr<FlatBufferModelAbslError> model_ptr =
FlatBufferModelAbslError::VerifyAndBuildFromBuffer(
model_content.data(), model_content.length());
if (model_ptr == nullptr) {
return absl::InvalidArgumentError("Failed to build model from buffer.");
}

mlir::MLIRContext mlir_context;
mlir::DialectRegistry registry;
Expand Down

0 comments on commit c90bc64

Please sign in to comment.