Skip to content
Snippets Groups Projects
Verified Commit 1de9e3f9 authored by Joe Donofry's avatar Joe Donofry
Browse files

Fix some potential out_of_range json errors

parent dedb269d
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ namespace state {
void
from_json(const json &obj, CanonicalAlias &canonical_alias)
{
if (!obj.at("alias").is_null())
if (obj.find("alias") != obj.end() && !obj.at("alias").is_null())
canonical_alias.alias = obj.at("alias").get<std::string>();
}
......
......@@ -12,7 +12,7 @@ namespace state {
void
from_json(const json &obj, Name &event)
{
if (!obj.at("name").is_null())
if (obj.find("name") != obj.end() && !obj.at("name").is_null())
event.name = obj.at("name").get<std::string>();
}
......
......@@ -11,7 +11,7 @@ namespace state {
void
from_json(const json &obj, Topic &event)
{
if (!obj.at("topic").is_null())
if (obj.find("topic") != obj.end() && !obj.at("topic").is_null())
event.topic = obj.at("topic").get<std::string>();
}
......
......@@ -14,7 +14,7 @@ from_json(const json &obj, Notification &res)
res.room_id = obj.at("room_id");
res.ts = obj.at("ts");
if (!obj.at("profile_tag").is_null())
if (obj.find("profile_tag") != obj.end() && !obj.at("profile_tag").is_null())
res.profile_tag = obj.at("profile_tag");
// HACK to work around the fact that there isn't
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment