summaryrefslogtreecommitdiff
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-07 13:49:33 +0200
committerGitHub <noreply@github.com>2019-08-07 13:49:33 +0200
commitba541bceca806a53070a4fd54955ac4a63c1633a (patch)
treea03f55aa6d660a7c3659705348842a3e5b208e54 /scene/main/node.cpp
parent904e3100aceee7560e24ae1293c5b8a1e6201d55 (diff)
parente0b5b218638df5b7b2998233182a7d8a1118e717 (diff)
Merge pull request #31077 from qarmin/coverity_bugs
Change some code proposed by Coverity and Cppcheck
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index caa0da5d1f..bfb4881843 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1021,7 +1021,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
if (!unique) {
- node_hrcr_count.ref();
+ ERR_FAIL_COND(!node_hrcr_count.ref());
String name = "@" + String(p_child->get_name()) + "@" + itos(node_hrcr_count.get());
p_child->data.name = name;
}
@@ -2198,8 +2198,11 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL_COND(!obj);
node = Object::cast_to<Node>(obj);
- if (!node)
+ if (!node) {
memdelete(obj);
+ ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
+ ERR_FAIL();
+ }
}
List<PropertyInfo> plist;
@@ -2295,16 +2298,16 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
ERR_FAIL_COND_V(get_filename() != "", NULL);
- Node *node = NULL;
-
Object *obj = ClassDB::instance(get_class());
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL_COND_V(!obj, NULL);
- node = Object::cast_to<Node>(obj);
- if (!node)
- memdelete(obj);
- ERR_FAIL_COND_V(!node, NULL);
+ Node *node = Object::cast_to<Node>(obj);
+ if (!node) {
+ memdelete(obj);
+ ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
+ ERR_FAIL_V(NULL);
+ }
node->set_name(get_name());
List<PropertyInfo> plist;