Merge lp:~marcustomlinson/unity-scopes-api/lp-1494796 into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson on 2015-09-15
Status: Merged
Approved by: Paweł Stołowski on 2015-09-15
Approved revision: 630
Merged at revision: 630
Proposed branch: lp:~marcustomlinson/unity-scopes-api/lp-1494796
Merge into: lp:unity-scopes-api/devel
Diff against target: 27 lines (+10/-0)
1 file modified
src/scopes/internal/JsonCppNode.cpp (+10/-0)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/lp-1494796
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2015-09-15
Paweł Stołowski 2015-09-15 Approve on 2015-09-15
Review via email: mp+271079@code.launchpad.net

Commit message

Protect all JsonCppNode::get_node() methods with a "if (!root_) throw;" check

To post a comment you must log in.
Paweł Stołowski (stolowski) wrote :

Yeah, looking good, thanks!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/scopes/internal/JsonCppNode.cpp'
2--- src/scopes/internal/JsonCppNode.cpp 2015-07-13 08:44:43 +0000
3+++ src/scopes/internal/JsonCppNode.cpp 2015-09-15 09:13:51 +0000
4@@ -279,6 +279,11 @@
5
6 JsonNodeInterface::SPtr JsonCppNode::get_node(std::string const& node_name) const
7 {
8+ if (!root_)
9+ {
10+ throw unity::LogicException("Current node is empty");
11+ }
12+
13 if (!root_.isMember(node_name))
14 {
15 throw unity::LogicException("Node " + node_name + " does not exist");
16@@ -290,6 +295,11 @@
17
18 JsonNodeInterface::SPtr JsonCppNode::get_node(unsigned int node_index) const
19 {
20+ if (!root_)
21+ {
22+ throw unity::LogicException("Current node is empty");
23+ }
24+
25 if (root_.type() != Json::arrayValue)
26 {
27 throw unity::LogicException("Root node is not an array");

Subscribers

People subscribed via source and target branches

to all changes: