summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/xml_parser.cpp8
-rw-r--r--editor/spatial_editor_gizmos.cpp2
-rw-r--r--scene/resources/dynamic_font.cpp11
3 files changed, 18 insertions, 3 deletions
diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp
index 53e7da91a7..bd450dd84f 100644
--- a/core/io/xml_parser.cpp
+++ b/core/io/xml_parser.cpp
@@ -471,6 +471,10 @@ Error XMLParser::open_buffer(const Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V(p_buffer.size() == 0, ERR_INVALID_DATA);
+ if (data) {
+ memdelete_arr(data);
+ }
+
length = p_buffer.size();
data = memnew_arr(char, length + 1);
copymem(data, p_buffer.ptr(), length);
@@ -489,6 +493,10 @@ Error XMLParser::open(const String &p_path) {
length = file->get_len();
ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT);
+ if (data) {
+ memdelete_arr(data);
+ }
+
data = memnew_arr(char, length + 1);
file->get_buffer((uint8_t *)data, length);
data[length] = 0;
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 89713c2579..418ff1d2a3 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -885,7 +885,7 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx,
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
}
- if (d < 0)
+ if (d <= 0) // Equal is here for negative zero.
d = 0;
light->set_param(Light::PARAM_RANGE, d);
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 8b619345d6..a21015f872 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -130,7 +130,10 @@ Error DynamicFontAtSize::_load() {
} else {
FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'.");
+ if (!f) {
+ FT_Done_FreeType(library);
+ ERR_FAIL_V_MSG(ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'.");
+ }
size_t len = f->get_len();
_fontdata[font->font_path] = Vector<uint8_t>();
@@ -145,7 +148,10 @@ Error DynamicFontAtSize::_load() {
if (font->font_mem == NULL && font->font_path != String()) {
FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'.");
+ if (!f) {
+ FT_Done_FreeType(library);
+ ERR_FAIL_V_MSG(ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'.");
+ }
memset(&stream, 0, sizeof(FT_StreamRec));
stream.base = NULL;
@@ -176,6 +182,7 @@ Error DynamicFontAtSize::_load() {
error = FT_Open_Face(library, &fargs, 0, &face);
} else {
+ FT_Done_FreeType(library);
ERR_FAIL_V_MSG(ERR_UNCONFIGURED, "DynamicFont uninitialized.");
}