Memory leak and crash fixes

This commit is contained in:
Rafał Mikrut 2019-11-10 09:49:13 +01:00
parent 4569f5ec82
commit 7dda9309f9
10 changed files with 24 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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();
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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;

View File

@ -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());
}
}

View File

@ -297,4 +297,5 @@ void AudioEffectRecord::_bind_methods() {
AudioEffectRecord::AudioEffectRecord() {
format = AudioStreamSample::FORMAT_16_BITS;
recording_active = false;
}