From 6e16f8ecd2ffb3638cc79c7679f19e5f59fa547f Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 20 Oct 2021 16:53:01 -0700 Subject: [PATCH] Call rapidjson::ParseResult::IsError to check for JSON parsing errors (flutter/engine#29270) --- engine/src/flutter/common/graphics/persistent_cache.cc | 2 +- .../src/flutter/shell/platform/common/json_message_codec.cc | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/common/graphics/persistent_cache.cc b/engine/src/flutter/common/graphics/persistent_cache.cc index 88889b757b..5c38120bd5 100644 --- a/engine/src/flutter/common/graphics/persistent_cache.cc +++ b/engine/src/flutter/common/graphics/persistent_cache.cc @@ -253,7 +253,7 @@ std::vector PersistentCache::LoadSkSLs() const { rapidjson::ParseResult parse_result = json_doc.Parse(reinterpret_cast(mapping->GetMapping()), mapping->GetSize()); - if (parse_result != rapidjson::ParseErrorCode::kParseErrorNone) { + if (parse_result.IsError()) { FML_LOG(ERROR) << "Failed to parse json file: " << kAssetFileName; } else { for (auto& item : json_doc["data"].GetObject()) { diff --git a/engine/src/flutter/shell/platform/common/json_message_codec.cc b/engine/src/flutter/shell/platform/common/json_message_codec.cc index b91e57e412..ae362f736c 100644 --- a/engine/src/flutter/shell/platform/common/json_message_codec.cc +++ b/engine/src/flutter/shell/platform/common/json_message_codec.cc @@ -37,9 +37,7 @@ std::unique_ptr JsonMessageCodec::DecodeMessageInternal( auto json_message = std::make_unique(); rapidjson::ParseResult result = json_message->Parse(raw_message, message_size); - bool parsing_successful = - result == rapidjson::ParseErrorCode::kParseErrorNone; - if (!parsing_successful) { + if (result.IsError()) { std::cerr << "Unable to parse JSON message:" << std::endl << rapidjson::GetParseError_En(result.Code()) << std::endl; return nullptr;