summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-06 13:43:38 +0100
committerGitHub <noreply@github.com>2020-01-06 13:43:38 +0100
commit080e6e48ad0bdab8385e6ec3fc4636fc86a4b4a7 (patch)
tree142df91ec75860ff3acb9ee7acb4b518e3cbb3b3 /scene/resources
parent845480497207839bef48997d152f00b60b6176a8 (diff)
parent4b660a87d86cc4db00b562b82759adf1a88d4e20 (diff)
Merge pull request #34829 from timothyqiu/checks-bundle
Fixes crash for bad property of PackedScene
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/packed_scene.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 5a2cd9a1c2..14e024a496 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -1097,6 +1097,14 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
ERR_FAIL_COND_MSG(version > PACK_VERSION, "Save format version too new.");
+ const int node_count = p_dictionary["node_count"];
+ const PoolVector<int> snodes = p_dictionary["nodes"];
+ ERR_FAIL_COND(snodes.size() != node_count);
+
+ const int conn_count = p_dictionary["conn_count"];
+ const PoolVector<int> sconns = p_dictionary["conns"];
+ ERR_FAIL_COND(sconns.size() != conn_count);
+
PoolVector<String> snames = p_dictionary["names"];
if (snames.size()) {
@@ -1121,13 +1129,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
variants.clear();
}
- nodes.resize(p_dictionary["node_count"]);
- int nc = nodes.size();
- if (nc) {
- PoolVector<int> snodes = p_dictionary["nodes"];
+ nodes.resize(node_count);
+ if (node_count) {
PoolVector<int>::Read r = snodes.read();
int idx = 0;
- for (int i = 0; i < nc; i++) {
+ for (int i = 0; i < node_count; i++) {
NodeData &nd = nodes.write[i];
nd.parent = r[idx++];
nd.owner = r[idx++];
@@ -1151,15 +1157,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
}
}
- connections.resize(p_dictionary["conn_count"]);
- int cc = connections.size();
-
- if (cc) {
-
- PoolVector<int> sconns = p_dictionary["conns"];
+ connections.resize(conn_count);
+ if (conn_count) {
PoolVector<int>::Read r = sconns.read();
int idx = 0;
- for (int i = 0; i < cc; i++) {
+ for (int i = 0; i < conn_count; i++) {
ConnectionData &cd = connections.write[i];
cd.from = r[idx++];
cd.to = r[idx++];