1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

fix: clang-analyzer-core.NullDereference warning in tr_variant_serde::parse_json() (#6236)

This commit is contained in:
Charles Kerr 2023-11-10 08:46:17 -06:00 committed by GitHub
parent 36f33c0d30
commit 879258d62b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -222,10 +222,13 @@ std::optional<tr_variant> tr_variant_serde::parse_json(std::string_view input)
{
auto* const begin = std::data(input);
TR_ASSERT(begin != nullptr); // RapidJSON will dereference a nullptr if this is false
if (begin == nullptr)
{
return {};
}
auto const size = std::size(input);
auto top = tr_variant{};
auto handler = parse_helpers::json_to_variant_handler{ &top };
auto ms = rapidjson::MemoryStream{ begin, size };
auto eis = rapidjson::AutoUTFInputStream<unsigned, rapidjson::MemoryStream>{ ms };