From 15cccb331f64ceb5e24461d6132e3c1761b787e2 Mon Sep 17 00:00:00 2001 From: Bastien JAUNY Date: Sun, 10 Oct 2021 17:49:50 +0200 Subject: [PATCH] Fix unitialized variables in `core` --- core/bind/core_bind.cpp | 2 ++ core/config/engine.cpp | 1 + core/containers/packed_data_container.cpp | 1 + core/crypto/hashing_context.cpp | 1 + core/io/file_access_compressed.cpp | 1 + core/io/file_access_encrypted.cpp | 2 ++ core/io/file_access_memory.cpp | 2 ++ core/io/http_client.cpp | 1 + core/io/pck_packer.cpp | 1 + core/io/resource_format_binary.cpp | 2 ++ core/math/a_star.h | 6 +++++- core/math/expression.cpp | 2 ++ core/math/expression.h | 13 ++++++++++++- core/object/class_db.cpp | 1 + core/object/object.h | 5 ++++- core/object/script_debugger_local.cpp | 4 ++++ core/os/dir_access.cpp | 1 + 17 files changed, 43 insertions(+), 3 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 9ca0e8e64..31458d78d 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2606,6 +2606,8 @@ void _Directory::_bind_methods() { _Directory::_Directory() { d = DirAccess::create(DirAccess::ACCESS_RESOURCES); + _list_skip_navigational = false; + _list_skip_hidden = false; } _Directory::~_Directory() { diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 05dd01737..a9292d8dd 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -274,6 +274,7 @@ Engine::Engine() { _frame_step = 0; editor_hint = false; _portals_active = false; + _occlusion_culling_active = false; } Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) : diff --git a/core/containers/packed_data_container.cpp b/core/containers/packed_data_container.cpp index bffff739a..7ee655028 100644 --- a/core/containers/packed_data_container.cpp +++ b/core/containers/packed_data_container.cpp @@ -402,4 +402,5 @@ int PackedDataContainerRef::size() const { }; PackedDataContainerRef::PackedDataContainerRef() { + offset = 0; } diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp index 7023f70d3..4a1f5d1cb 100644 --- a/core/crypto/hashing_context.cpp +++ b/core/crypto/hashing_context.cpp @@ -130,6 +130,7 @@ void HashingContext::_bind_methods() { HashingContext::HashingContext() { ctx = nullptr; + type = HashType::HASH_MD5; } HashingContext::~HashingContext() { diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index cbbadcb2f..bb63ec919 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -396,6 +396,7 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t FileAccessCompressed::FileAccessCompressed() : cmode(Compression::MODE_ZSTD), writing(false), + write_pos(0), write_ptr(nullptr), write_buffer_size(0), write_max(0), diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 8dd00b1aa..909ce7602 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -297,6 +297,8 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t FileAccessEncrypted::FileAccessEncrypted() { file = nullptr; + base = 0; + length = 0; pos = 0; eofed = false; mode = MODE_MAX; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index d8cb1883e..533707bb8 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -182,4 +182,6 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, uint64_t p_length) { FileAccessMemory::FileAccessMemory() { data = nullptr; + length = 0; + pos = 0; } diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 83b24664f..2f599a14f 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -836,6 +836,7 @@ HTTPClient::HTTPClient() { chunk_trailer_part = false; response_num = 0; ssl = false; + ssl_verify_host = false; blocking = false; handshaking = false; // 64 KiB by default (favors fast download speeds at the cost of memory usage). diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 40a8f56bf..b1c81f223 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -178,6 +178,7 @@ Error PCKPacker::flush(bool p_verbose) { PCKPacker::PCKPacker() { file = nullptr; + alignment = 0; }; PCKPacker::~PCKPacker() { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 1b7b7659a..eebceccbd 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1043,7 +1043,9 @@ String ResourceInteractiveLoaderBinary::recognize(FileAccess *p_f) { ResourceInteractiveLoaderBinary::ResourceInteractiveLoaderBinary() : translation_remapped(false), + ver_format(0), f(nullptr), + importmd_ofs(0), error(OK), stage(0) { } diff --git a/core/math/a_star.h b/core/math/a_star.h index f079a336c..5738a13e7 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -47,8 +47,12 @@ class AStar : public Reference { struct Point { Point() : + id(0), + enabled(false), neighbours(4u), - unlinked_neighbours(4u) {} + unlinked_neighbours(4u), + prev_point(nullptr), + open_pass(0) {} int id; Vector3 pos; diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 7a1b47aa3..dbead6b47 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -2227,6 +2227,8 @@ void Expression::_bind_methods() { Expression::Expression() : output_type(Variant::NIL), sequenced(false), + str_ofs(0), + expression_dirty(false), error_set(true), root(nullptr), nodes(nullptr), diff --git a/core/math/expression.h b/core/math/expression.h index 6d7909d12..7a384ac06 100644 --- a/core/math/expression.h +++ b/core/math/expression.h @@ -219,7 +219,10 @@ private: Type type; - ENode() { next = nullptr; } + ENode() { + type = Type::TYPE_INPUT; + next = nullptr; + } virtual ~ENode() { if (next) { memdelete(next); @@ -241,6 +244,7 @@ private: int index; InputNode() { type = TYPE_INPUT; + index = 0; } }; @@ -258,6 +262,8 @@ private: OperatorNode() { type = TYPE_OPERATOR; + nodes[0] = nullptr; + nodes[1] = nullptr; } }; @@ -273,6 +279,8 @@ private: IndexNode() { type = TYPE_INDEX; + base = nullptr; + index = nullptr; } }; @@ -282,6 +290,7 @@ private: NamedIndexNode() { type = TYPE_NAMED_INDEX; + base = nullptr; } }; @@ -301,6 +310,7 @@ private: CallNode() { type = TYPE_CALL; + base = nullptr; } }; @@ -323,6 +333,7 @@ private: Vector arguments; BuiltinFuncNode() { type = TYPE_BUILTIN_FUNC; + func = BuiltinFunc::MATH_SIN; } }; diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 34e3ad358..18da72003 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -249,6 +249,7 @@ ClassDB::ClassInfo::ClassInfo() { inherits_ptr = nullptr; disabled = false; exposed = false; + class_ptr = nullptr; } ClassDB::ClassInfo::~ClassInfo() { diff --git a/core/object/object.h b/core/object/object.h index 681356ad4..bea207f05 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -475,7 +475,10 @@ private: int reference_count; Connection conn; List::Element *cE; - Slot() { reference_count = 0; } + Slot() { + reference_count = 0; + cE = nullptr; + } }; MethodInfo user; diff --git a/core/object/script_debugger_local.cpp b/core/object/script_debugger_local.cpp index 60fdecd49..7cba75fc1 100644 --- a/core/object/script_debugger_local.cpp +++ b/core/object/script_debugger_local.cpp @@ -385,6 +385,10 @@ void ScriptDebuggerLocal::send_error(const String &p_func, const String &p_file, ScriptDebuggerLocal::ScriptDebuggerLocal() { profiling = false; + frame_time = 0.0f; + process_time = 0.0f; + physics_time = 0.0f; + physics_frame_time = 0.0f; idle_accum = OS::get_singleton()->get_ticks_usec(); options["variable_prefix"] = ""; } diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index f65962a49..fa7f1d656 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -479,6 +479,7 @@ String DirAccess::get_filesystem_abspath_for(String p_path) { DirAccess::DirAccess() { _access_type = ACCESS_FILESYSTEM; + next_is_dir = false; } DirAccess::~DirAccess() {