summaryrefslogtreecommitdiffstats
path: root/scene/resources/texture.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-11-10 10:17:19 +0100
committerGitHub <noreply@github.com>2019-11-10 10:17:19 +0100
commit2143f46df26bde529db350f4b5965a6508385c2f (patch)
treed4bdab6220f7e24d7fad88087fb6c566bd6ff2b2 /scene/resources/texture.cpp
parent2fdeed1b4f3820bebf9f39d69eb8bd59e1c4f2f2 (diff)
parent7dda9309f91a71b9b3e2088f11bc322e3c15d669 (diff)
downloadredot-engine-2143f46df26bde529db350f4b5965a6508385c2f.tar.gz
Merge pull request #33516 from qarmin/small_fixes
Memory leaks and crash fixes
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r--scene/resources/texture.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index c2e2f85723..593c399f62 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -2369,16 +2369,20 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
if (header[0] == 'G' && header[1] == 'D' && header[2] == '3' && header[3] == 'T') {
if (tex3d.is_null()) {
+ f->close();
memdelete(f);
ERR_FAIL_COND_V(tex3d.is_null(), RES())
}
} else if (header[0] == 'G' && header[1] == 'D' && header[2] == 'A' && header[3] == 'T') {
if (texarr.is_null()) {
+ f->close();
memdelete(f);
ERR_FAIL_COND_V(texarr.is_null(), RES())
}
} else {
+ f->close();
+ memdelete(f);
ERR_FAIL_V_MSG(RES(), "Unrecognized layered texture file format '" + String((const char *)header) + "'.");
}
@@ -2418,6 +2422,7 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
if (r_error) {
*r_error = ERR_FILE_CORRUPT;
}
+ f->close();
memdelete(f);
ERR_FAIL_V(RES());
}
@@ -2453,6 +2458,7 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
if (r_error) {
*r_error = ERR_FILE_CORRUPT;
}
+ f->close();
memdelete(f);
ERR_FAIL_V(RES());
}
@@ -2473,8 +2479,9 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
if (bytes != total_size) {
if (r_error) {
*r_error = ERR_FILE_CORRUPT;
- memdelete(f);
}
+ f->close();
+ memdelete(f);
ERR_FAIL_V(RES());
}
}