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

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Paweł Stołowski
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
Paweł Stołowski (community) Approve
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.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Yeah, looking good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/scopes/internal/JsonCppNode.cpp'
--- src/scopes/internal/JsonCppNode.cpp 2015-07-13 08:44:43 +0000
+++ src/scopes/internal/JsonCppNode.cpp 2015-09-15 09:13:51 +0000
@@ -279,6 +279,11 @@
279279
280JsonNodeInterface::SPtr JsonCppNode::get_node(std::string const& node_name) const280JsonNodeInterface::SPtr JsonCppNode::get_node(std::string const& node_name) const
281{281{
282 if (!root_)
283 {
284 throw unity::LogicException("Current node is empty");
285 }
286
282 if (!root_.isMember(node_name))287 if (!root_.isMember(node_name))
283 {288 {
284 throw unity::LogicException("Node " + node_name + " does not exist");289 throw unity::LogicException("Node " + node_name + " does not exist");
@@ -290,6 +295,11 @@
290295
291JsonNodeInterface::SPtr JsonCppNode::get_node(unsigned int node_index) const296JsonNodeInterface::SPtr JsonCppNode::get_node(unsigned int node_index) const
292{297{
298 if (!root_)
299 {
300 throw unity::LogicException("Current node is empty");
301 }
302
293 if (root_.type() != Json::arrayValue)303 if (root_.type() != Json::arrayValue)
294 {304 {
295 throw unity::LogicException("Root node is not an array");305 throw unity::LogicException("Root node is not an array");

Subscribers

People subscribed via source and target branches

to all changes: