summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Mikrut <mikrutrafal54@gmail.com>2019-11-10 09:49:13 +0100
committerRafał Mikrut <mikrutrafal54@gmail.com>2019-11-10 09:49:13 +0100
commit7dda9309f91a71b9b3e2088f11bc322e3c15d669 (patch)
tree386dffec57cc0d7b712889a980c4aa5038bb7fbd
parent4569f5ec82964e0abe543337c9537e0af9164c11 (diff)
Memory leak and crash fixes
-rw-r--r--editor/editor_resource_preview.cpp1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp1
-rw-r--r--editor/plugins/editor_preview_plugins.cpp8
-rw-r--r--modules/etc/texture_loader_pkm.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp2
-rw-r--r--modules/webm/video_stream_webm.cpp2
-rw-r--r--scene/gui/range.cpp1
-rw-r--r--scene/gui/tree.cpp1
-rw-r--r--scene/resources/texture.cpp9
-rw-r--r--servers/audio/effects/audio_effect_record.cpp1
10 files changed, 24 insertions, 4 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 55f9347045..e383dadfb0 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -207,6 +207,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
f->store_line(itos(has_small_texture));
f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
f->store_line(FileAccess::get_md5(p_item.path));
+ f->close();
memdelete(f);
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 119c61deb1..e5042513c8 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5215,6 +5215,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
snap_other_nodes = true;
snap_guides = true;
snap_rotation = false;
+ snap_scale = false;
snap_relative = false;
snap_pixel = false;
snap_target[0] = SNAP_TARGET_NONE;
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 8acc41a2c7..007ce58bd7 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -103,9 +103,11 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
img = ltex->to_image();
} else {
Ref<Texture> tex = p_from;
- img = tex->get_data();
- if (img.is_valid()) {
- img = img->duplicate();
+ if (tex.is_valid()) {
+ img = tex->get_data();
+ if (img.is_valid()) {
+ img = img->duplicate();
+ }
}
}
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index 4d8af6883f..da6da74025 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -91,6 +91,8 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
if (r_error)
*r_error = OK;
+ f->close();
+ memdelete(f);
return texture;
}
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index ed1a7f682b..12f07aa773 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -741,6 +741,8 @@ RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_origi
*r_error = OK;
}
+ f->close();
+ memdelete(f);
return ogv_stream;
}
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 4ce0db3746..54b284f939 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -484,6 +484,8 @@ RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_origina
*r_error = OK;
}
+ f->close();
+ memdelete(f);
return webm_stream;
}
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index ed5dd77f53..9c016b5a50 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -213,6 +213,7 @@ void Range::unshare() {
nshared->val = shared->val;
nshared->step = shared->step;
nshared->page = shared->page;
+ nshared->exp_ratio = shared->exp_ratio;
nshared->allow_greater = shared->allow_greater;
nshared->allow_lesser = shared->allow_lesser;
_unref_shared();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index c9d1295557..e064b9f913 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -4050,6 +4050,7 @@ Tree::Tree() {
drop_mode_section = 0;
single_select_defer = NULL;
+ scrolling = false;
allow_rmb_select = false;
force_edit_checkbox_only_on_checkbox = false;
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());
}
}
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index 1390ab55c4..83d78daff4 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -297,4 +297,5 @@ void AudioEffectRecord::_bind_methods() {
AudioEffectRecord::AudioEffectRecord() {
format = AudioStreamSample::FORMAT_16_BITS;
+ recording_active = false;
}