Merge pull request #33516 from qarmin/small_fixes

Memory leaks and crash fixes
This commit is contained in:
Rémi Verschelde 2019-11-10 10:17:19 +01:00 committed by GitHub
commit 2143f46df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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

@ -5247,6 +5247,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

@ -4049,6 +4049,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;
}