Browse Source

Merge pull request #53639 from bjauny/fix_uninitMemberVar_core

[3.x] Fix unitialized variables in `core`
Rémi Verschelde 1 year ago
parent
commit
e22335ec72

+ 2 - 0
core/bind/core_bind.cpp

@@ -2602,6 +2602,8 @@ void _Directory::_bind_methods() {
 
 _Directory::_Directory() {
 	d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+	_list_skip_navigational = false;
+	_list_skip_hidden = false;
 }
 
 _Directory::~_Directory() {

+ 1 - 0
core/class_db.cpp

@@ -248,6 +248,7 @@ ClassDB::ClassInfo::ClassInfo() {
 	inherits_ptr = nullptr;
 	disabled = false;
 	exposed = false;
+	class_ptr = nullptr;
 }
 
 ClassDB::ClassInfo::~ClassInfo() {

+ 1 - 0
core/crypto/hashing_context.cpp

@@ -129,6 +129,7 @@ void HashingContext::_bind_methods() {
 
 HashingContext::HashingContext() {
 	ctx = nullptr;
+	type = HashType::HASH_MD5;
 }
 
 HashingContext::~HashingContext() {

+ 1 - 0
core/engine.cpp

@@ -236,6 +236,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) :

+ 1 - 0
core/io/file_access_compressed.cpp

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

+ 2 - 0
core/io/file_access_encrypted.cpp

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

+ 2 - 0
core/io/file_access_memory.cpp

@@ -181,4 +181,6 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, uint64_t p_length) {
 
 FileAccessMemory::FileAccessMemory() {
 	data = nullptr;
+	length = 0;
+	pos = 0;
 }

+ 1 - 0
core/io/http_client.cpp

@@ -835,6 +835,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).

+ 1 - 0
core/io/pck_packer.cpp

@@ -177,6 +177,7 @@ Error PCKPacker::flush(bool p_verbose) {
 
 PCKPacker::PCKPacker() {
 	file = nullptr;
+	alignment = 0;
 };
 
 PCKPacker::~PCKPacker() {

+ 2 - 0
core/io/resource_format_binary.cpp

@@ -937,7 +937,9 @@ String ResourceInteractiveLoaderBinary::recognize(FileAccess *p_f) {
 
 ResourceInteractiveLoaderBinary::ResourceInteractiveLoaderBinary() :
 		translation_remapped(false),
+		ver_format(0),
 		f(nullptr),
+		importmd_ofs(0),
 		error(OK),
 		stage(0) {
 }

+ 5 - 1
core/math/a_star.h

@@ -46,8 +46,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;

+ 2 - 0
core/math/expression.cpp

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

+ 12 - 1
core/math/expression.h

@@ -218,7 +218,10 @@ private:
 
 		Type type;
 
-		ENode() { next = nullptr; }
+		ENode() {
+			type = Type::TYPE_INPUT;
+			next = nullptr;
+		}
 		virtual ~ENode() {
 			if (next) {
 				memdelete(next);
@@ -240,6 +243,7 @@ private:
 		int index;
 		InputNode() {
 			type = TYPE_INPUT;
+			index = 0;
 		}
 	};
 
@@ -257,6 +261,8 @@ private:
 
 		OperatorNode() {
 			type = TYPE_OPERATOR;
+			nodes[0] = nullptr;
+			nodes[1] = nullptr;
 		}
 	};
 
@@ -272,6 +278,8 @@ private:
 
 		IndexNode() {
 			type = TYPE_INDEX;
+			base = nullptr;
+			index = nullptr;
 		}
 	};
 
@@ -281,6 +289,7 @@ private:
 
 		NamedIndexNode() {
 			type = TYPE_NAMED_INDEX;
+			base = nullptr;
 		}
 	};
 
@@ -300,6 +309,7 @@ private:
 
 		CallNode() {
 			type = TYPE_CALL;
+			base = nullptr;
 		}
 	};
 
@@ -322,6 +332,7 @@ private:
 		Vector<ENode *> arguments;
 		BuiltinFuncNode() {
 			type = TYPE_BUILTIN_FUNC;
+			func = BuiltinFunc::MATH_SIN;
 		}
 	};
 

+ 4 - 1
core/object.h

@@ -465,7 +465,10 @@ private:
 			int reference_count;
 			Connection conn;
 			List<Connection>::Element *cE;
-			Slot() { reference_count = 0; }
+			Slot() {
+				reference_count = 0;
+				cE = nullptr;
+			}
 		};
 
 		MethodInfo user;

+ 1 - 0
core/os/dir_access.cpp

@@ -448,6 +448,7 @@ bool DirAccess::exists(String p_dir) {
 
 DirAccess::DirAccess() {
 	_access_type = ACCESS_FILESYSTEM;
+	next_is_dir = false;
 }
 
 DirAccess::~DirAccess() {

+ 1 - 0
core/packed_data_container.cpp

@@ -400,4 +400,5 @@ int PackedDataContainerRef::size() const {
 };
 
 PackedDataContainerRef::PackedDataContainerRef() {
+	offset = 0;
 }

+ 4 - 0
core/script_debugger_local.cpp

@@ -384,6 +384,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"] = "";
 }