Skip to content

Commit

Permalink
Memory leak and crash fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Nov 10, 2019
1 parent 4569f5e commit 7dda930
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions editor/editor_resource_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions editor/plugins/editor_preview_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/etc/texture_loader_pkm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions modules/theora/video_stream_theora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions modules/webm/video_stream_webm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions scene/gui/range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion scene/resources/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) + "'.");
}

Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
}
Expand Down
1 change: 1 addition & 0 deletions servers/audio/effects/audio_effect_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,5 @@ void AudioEffectRecord::_bind_methods() {

AudioEffectRecord::AudioEffectRecord() {
format = AudioStreamSample::FORMAT_16_BITS;
recording_active = false;
}

0 comments on commit 7dda930

Please sign in to comment.