2
0
Эх сурвалжийг харах

Merge pull request #10877 from hpvb/fix-unitialized-variables

Fix use of unitialized variables
Rémi Verschelde 8 жил өмнө
parent
commit
437fb12e1a
38 өөрчлөгдсөн 130 нэмэгдсэн , 87 устгасан
  1. 3 3
      core/image.cpp
  2. 2 2
      core/io/translation_loader_po.cpp
  3. 1 1
      core/math/face3.cpp
  4. 3 3
      core/math/quick_hull.cpp
  5. 2 1
      core/os/os.cpp
  6. 1 1
      core/reference.h
  7. 10 10
      core/ustring.cpp
  8. 5 1
      core/vmap.h
  9. 6 1
      core/vset.h
  10. 1 1
      drivers/gles3/rasterizer_scene_gles3.cpp
  11. 2 2
      drivers/unix/packet_peer_udp_posix.cpp
  12. 1 1
      drivers/unix/tcp_server_posix.cpp
  13. 4 1
      editor/editor_audio_buses.cpp
  14. 1 1
      editor/import/resource_importer_wav.cpp
  15. 11 11
      editor/plugins/canvas_item_editor_plugin.cpp
  16. 1 1
      editor/plugins/polygon_2d_editor_plugin.cpp
  17. 5 2
      editor/plugins/texture_region_editor_plugin.cpp
  18. 3 3
      modules/gdscript/gd_function.cpp
  19. 5 1
      modules/squish/image_compress_squish.cpp
  20. 2 0
      modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
  21. 2 0
      modules/stb_vorbis/audio_stream_ogg_vorbis.h
  22. 1 1
      modules/visual_script/visual_script_yield_nodes.cpp
  23. 8 8
      platform/android/export/export.cpp
  24. 3 1
      platform/uwp/export/export.cpp
  25. 1 1
      scene/2d/line_builder.cpp
  26. 5 1
      scene/3d/audio_stream_player_3d.cpp
  27. 2 2
      scene/3d/gi_probe.cpp
  28. 1 1
      scene/gui/label.cpp
  29. 1 1
      scene/gui/text_edit.cpp
  30. 2 2
      scene/main/viewport.cpp
  31. 8 3
      scene/resources/animation.cpp
  32. 6 1
      scene/resources/color_ramp.h
  33. 4 1
      scene/resources/font.cpp
  34. 1 1
      servers/physics/collision_solver_sw.cpp
  35. 3 3
      servers/physics/gjk_epa.cpp
  36. 5 5
      servers/physics/shape_sw.cpp
  37. 1 1
      servers/visual/shader_language.cpp
  38. 7 7
      servers/visual/visual_server_scene.cpp

+ 3 - 3
core/image.cpp

@@ -1256,9 +1256,9 @@ void Image::create(const char **p_xpm) {
 
 
 					if (*line_ptr == '#') {
 					if (*line_ptr == '#') {
 						line_ptr++;
 						line_ptr++;
-						uint8_t col_r;
-						uint8_t col_g;
-						uint8_t col_b;
+						uint8_t col_r = 0;
+						uint8_t col_g = 0;
+						uint8_t col_b = 0;
 						//uint8_t col_a=255;
 						//uint8_t col_a=255;
 
 
 						for (int i = 0; i < 6; i++) {
 						for (int i = 0; i < 6; i++) {

+ 2 - 2
core/io/translation_loader_po.cpp

@@ -51,8 +51,8 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
 
 
 	Ref<Translation> translation = Ref<Translation>(memnew(Translation));
 	Ref<Translation> translation = Ref<Translation>(memnew(Translation));
 	int line = 1;
 	int line = 1;
-	bool skip_this;
-	bool skip_next;
+	bool skip_this = false;
+	bool skip_next = false;
 
 
 	while (true) {
 	while (true) {
 
 

+ 1 - 1
core/math/face3.cpp

@@ -296,7 +296,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
 	/** FIND SUPPORT VERTEX **/
 	/** FIND SUPPORT VERTEX **/
 
 
 	int vert_support_idx = -1;
 	int vert_support_idx = -1;
-	real_t support_max;
+	real_t support_max = 0;
 
 
 	for (int i = 0; i < 3; i++) {
 	for (int i = 0; i < 3; i++) {
 
 

+ 3 - 3
core/math/quick_hull.cpp

@@ -76,7 +76,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
 	int simplex[4];
 	int simplex[4];
 
 
 	{
 	{
-		real_t max, min;
+		real_t max = 0, min = 0;
 
 
 		for (int i = 0; i < p_points.size(); i++) {
 		for (int i = 0; i < p_points.size(); i++) {
 
 
@@ -99,7 +99,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
 	//third vertex is one most further away from the line
 	//third vertex is one most further away from the line
 
 
 	{
 	{
-		real_t maxd;
+		real_t maxd = 0;
 		Vector3 rel12 = p_points[simplex[0]] - p_points[simplex[1]];
 		Vector3 rel12 = p_points[simplex[0]] - p_points[simplex[1]];
 
 
 		for (int i = 0; i < p_points.size(); i++) {
 		for (int i = 0; i < p_points.size(); i++) {
@@ -121,7 +121,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
 	//fourth vertex is the one  most further away from the plane
 	//fourth vertex is the one  most further away from the plane
 
 
 	{
 	{
-		real_t maxd;
+		real_t maxd = 0;
 		Plane p(p_points[simplex[0]], p_points[simplex[1]], p_points[simplex[2]]);
 		Plane p(p_points[simplex[0]], p_points[simplex[1]], p_points[simplex[2]]);
 
 
 		for (int i = 0; i < p_points.size(); i++) {
 		for (int i = 0; i < p_points.size(); i++) {

+ 2 - 1
core/os/os.cpp

@@ -64,12 +64,13 @@ void OS::debug_break(){
 
 
 void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
 void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
 
 
-	const char *err_type;
+	const char *err_type = "**ERROR**";
 	switch (p_type) {
 	switch (p_type) {
 		case ERR_ERROR: err_type = "**ERROR**"; break;
 		case ERR_ERROR: err_type = "**ERROR**"; break;
 		case ERR_WARNING: err_type = "**WARNING**"; break;
 		case ERR_WARNING: err_type = "**WARNING**"; break;
 		case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break;
 		case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break;
 		case ERR_SHADER: err_type = "**SHADER ERROR**"; break;
 		case ERR_SHADER: err_type = "**SHADER ERROR**"; break;
+		default: ERR_PRINT("Unknown error type"); break;
 	}
 	}
 
 
 	if (p_rationale && *p_rationale)
 	if (p_rationale && *p_rationale)

+ 1 - 1
core/reference.h

@@ -62,7 +62,7 @@ public:
 template <class T>
 template <class T>
 class Ref {
 class Ref {
 
 
-	T *reference;
+	T *reference = NULL;
 
 
 	void ref(const Ref &p_from) {
 	void ref(const Ref &p_from) {
 
 

+ 10 - 10
core/ustring.cpp

@@ -3655,12 +3655,12 @@ String String::sprintf(const Array &values, bool *error) const {
 	CharType *self = (CharType *)c_str();
 	CharType *self = (CharType *)c_str();
 	bool in_format = false;
 	bool in_format = false;
 	int value_index = 0;
 	int value_index = 0;
-	int min_chars;
-	int min_decimals;
-	bool in_decimals;
-	bool pad_with_zeroes;
-	bool left_justified;
-	bool show_sign;
+	int min_chars = 0;
+	int min_decimals = 0;
+	bool in_decimals = false;
+	bool pad_with_zeroes = false;
+	bool left_justified = false;
+	bool show_sign = false;
 
 
 	*error = true;
 	*error = true;
 
 
@@ -3687,12 +3687,12 @@ String String::sprintf(const Array &values, bool *error) const {
 					}
 					}
 
 
 					int64_t value = values[value_index];
 					int64_t value = values[value_index];
-					int base;
+					int base = 16;
 					bool capitalize = false;
 					bool capitalize = false;
 					switch (c) {
 					switch (c) {
 						case 'd': base = 10; break;
 						case 'd': base = 10; break;
 						case 'o': base = 8; break;
 						case 'o': base = 8; break;
-						case 'x': base = 16; break;
+						case 'x': break;
 						case 'X':
 						case 'X':
 							base = 16;
 							base = 16;
 							capitalize = true;
 							capitalize = true;
@@ -3842,7 +3842,7 @@ String String::sprintf(const Array &values, bool *error) const {
 					}
 					}
 					break;
 					break;
 				}
 				}
-				case '.': { // Float separtor.
+				case '.': { // Float separator.
 					if (in_decimals) {
 					if (in_decimals) {
 						return "too many decimal points in format";
 						return "too many decimal points in format";
 					}
 					}
@@ -3851,7 +3851,7 @@ String String::sprintf(const Array &values, bool *error) const {
 					break;
 					break;
 				}
 				}
 
 
-				case '*': { // Dyanmic width, based on value.
+				case '*': { // Dynamic width, based on value.
 					if (value_index >= values.size()) {
 					if (value_index >= values.size()) {
 						return "not enough arguments for format string";
 						return "not enough arguments for format string";
 					}
 					}

+ 5 - 1
core/vmap.h

@@ -60,9 +60,13 @@ class VMap {
 
 
 		int low = 0;
 		int low = 0;
 		int high = _data.size() - 1;
 		int high = _data.size() - 1;
-		int middle;
 		const _Pair *a = &_data[0];
 		const _Pair *a = &_data[0];
+		int middle = 0;
 
 
+#if DEBUG_ENABLED
+		if (low > high)
+			ERR_PRINT("low > high, this may be a bug");
+#endif
 		while (low <= high) {
 		while (low <= high) {
 			middle = (low + high) / 2;
 			middle = (low + high) / 2;
 
 

+ 6 - 1
core/vset.h

@@ -46,8 +46,13 @@ class VSet {
 
 
 		int low = 0;
 		int low = 0;
 		int high = _data.size() - 1;
 		int high = _data.size() - 1;
-		int middle;
 		const T *a = &_data[0];
 		const T *a = &_data[0];
+		int middle = 0;
+
+#if DEBUG_ENABLED
+		if (low > high)
+			ERR_PRINT("low > high, this may be a bug");
+#endif
 
 
 		while (low <= high) {
 		while (low <= high) {
 			middle = (low + high) / 2;
 			middle = (low + high) / 2;

+ 1 - 1
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -257,7 +257,7 @@ bool RasterizerSceneGLES3::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
 
 
 		int found_free_idx = -1; //found a free one
 		int found_free_idx = -1; //found a free one
 		int found_used_idx = -1; //found existing one, must steal it
 		int found_used_idx = -1; //found existing one, must steal it
-		uint64_t min_pass; // pass of the existing one, try to use the least recently used one (LRU fashion)
+		uint64_t min_pass = 0; // pass of the existing one, try to use the least recently used one (LRU fashion)
 
 
 		for (int j = 0; j < sc; j++) {
 		for (int j = 0; j < sc; j++) {
 			if (!sarr[j].owner.is_valid()) {
 			if (!sarr[j].owner.is_valid()) {

+ 2 - 2
drivers/unix/packet_peer_udp_posix.cpp

@@ -73,8 +73,8 @@ Error PacketPeerUDPPosix::get_packet(const uint8_t **r_buffer, int &r_buffer_siz
 	if (queue_count == 0)
 	if (queue_count == 0)
 		return ERR_UNAVAILABLE;
 		return ERR_UNAVAILABLE;
 
 
-	uint32_t size;
-	uint8_t type;
+	uint32_t size = 0;
+	uint8_t type = IP::TYPE_NONE;
 	rb.read(&type, 1, true);
 	rb.read(&type, 1, true);
 	if (type == IP::TYPE_IPV4) {
 	if (type == IP::TYPE_IPV4) {
 		uint8_t ip[4];
 		uint8_t ip[4];

+ 1 - 1
drivers/unix/tcp_server_posix.cpp

@@ -165,7 +165,7 @@ Ref<StreamPeerTCP> TCPServerPosix::take_connection() {
 	Ref<StreamPeerTCPPosix> conn = memnew(StreamPeerTCPPosix);
 	Ref<StreamPeerTCPPosix> conn = memnew(StreamPeerTCPPosix);
 	IP_Address ip;
 	IP_Address ip;
 
 
-	int port;
+	int port = 0;
 	_set_ip_addr_port(ip, port, &their_addr);
 	_set_ip_addr_port(ip, port, &their_addr);
 
 
 	conn->set_socket(fd, ip, port, sock_type);
 	conn->set_socket(fd, ip, port, sock_type);

+ 4 - 1
editor/editor_audio_buses.cpp

@@ -70,11 +70,14 @@ void EditorAudioBus::_notification(int p_what) {
 		float real_peak[2] = { -100, -100 };
 		float real_peak[2] = { -100, -100 };
 		bool activity_found = false;
 		bool activity_found = false;
 
 
-		int cc;
+		int cc = 0;
 		switch (AudioServer::get_singleton()->get_speaker_mode()) {
 		switch (AudioServer::get_singleton()->get_speaker_mode()) {
 			case AudioServer::SPEAKER_MODE_STEREO: cc = 1; break;
 			case AudioServer::SPEAKER_MODE_STEREO: cc = 1; break;
 			case AudioServer::SPEAKER_SURROUND_51: cc = 4; break;
 			case AudioServer::SPEAKER_SURROUND_51: cc = 4; break;
 			case AudioServer::SPEAKER_SURROUND_71: cc = 5; break;
 			case AudioServer::SPEAKER_SURROUND_71: cc = 5; break;
+			default:
+				ERR_PRINT("Unknown speaker_mode");
+				break;
 		}
 		}
 
 
 		for (int i = 0; i < cc; i++) {
 		for (int i = 0; i < cc; i++) {

+ 1 - 1
editor/import/resource_importer_wav.cpp

@@ -129,7 +129,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
 	int format_freq = 0;
 	int format_freq = 0;
 	int loop_begin = 0;
 	int loop_begin = 0;
 	int loop_end = 0;
 	int loop_end = 0;
-	int frames;
+	int frames = 0;
 
 
 	Vector<float> data;
 	Vector<float> data;
 
 

+ 11 - 11
editor/plugins/canvas_item_editor_plugin.cpp

@@ -1881,7 +1881,7 @@ void CanvasItemEditor::_viewport_draw() {
 	if (snap_show_grid) {
 	if (snap_show_grid) {
 		//Draw the grid
 		//Draw the grid
 		Size2 s = viewport->get_size();
 		Size2 s = viewport->get_size();
-		int last_cell;
+		int last_cell = 0;
 		Transform2D xform = transform.affine_inverse();
 		Transform2D xform = transform.affine_inverse();
 
 
 		Vector2 grid_offset;
 		Vector2 grid_offset;
@@ -2257,17 +2257,17 @@ void CanvasItemEditor::_notification(int p_what) {
 				anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT);
 				anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT);
 				anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP);
 				anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP);
 				anchors[MARGIN_BOTTOM] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_BOTTOM);
 				anchors[MARGIN_BOTTOM] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_BOTTOM);
-			}
 
 
-			if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) {
-				viewport->update();
-				se->prev_rect = r;
-				se->prev_xform = xform;
-				se->prev_pivot = pivot;
-				se->prev_anchors[MARGIN_LEFT] = anchors[MARGIN_LEFT];
-				se->prev_anchors[MARGIN_RIGHT] = anchors[MARGIN_RIGHT];
-				se->prev_anchors[MARGIN_TOP] = anchors[MARGIN_TOP];
-				se->prev_anchors[MARGIN_BOTTOM] = anchors[MARGIN_BOTTOM];
+				if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) {
+					viewport->update();
+					se->prev_rect = r;
+					se->prev_xform = xform;
+					se->prev_pivot = pivot;
+					se->prev_anchors[MARGIN_LEFT] = anchors[MARGIN_LEFT];
+					se->prev_anchors[MARGIN_RIGHT] = anchors[MARGIN_RIGHT];
+					se->prev_anchors[MARGIN_TOP] = anchors[MARGIN_TOP];
+					se->prev_anchors[MARGIN_BOTTOM] = anchors[MARGIN_BOTTOM];
+				}
 			}
 			}
 		}
 		}
 
 

+ 1 - 1
editor/plugins/polygon_2d_editor_plugin.cpp

@@ -659,7 +659,7 @@ void Polygon2DEditor::_uv_draw() {
 
 
 	if (snap_show_grid) {
 	if (snap_show_grid) {
 		Size2 s = uv_edit_draw->get_size();
 		Size2 s = uv_edit_draw->get_size();
-		int last_cell;
+		int last_cell = 0;
 
 
 		if (snap_step.x != 0) {
 		if (snap_step.x != 0) {
 			for (int i = 0; i < s.width; i++) {
 			for (int i = 0; i < s.width; i++) {

+ 5 - 2
editor/plugins/texture_region_editor_plugin.cpp

@@ -67,7 +67,7 @@ void TextureRegionEditor::_region_draw() {
 
 
 	if (snap_mode == SNAP_GRID) {
 	if (snap_mode == SNAP_GRID) {
 		Size2 s = edit_draw->get_size();
 		Size2 s = edit_draw->get_size();
-		int last_cell;
+		int last_cell = 0;
 
 
 		if (snap_step.x != 0) {
 		if (snap_step.x != 0) {
 			if (snap_separation.x == 0)
 			if (snap_separation.x == 0)
@@ -406,7 +406,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
 		} else if (drag) {
 		} else if (drag) {
 
 
 			if (edited_margin >= 0) {
 			if (edited_margin >= 0) {
-				float new_margin;
+				float new_margin = 0;
 				if (edited_margin == 0)
 				if (edited_margin == 0)
 					new_margin = prev_margin + (mm->get_position().y - drag_from.y) / draw_zoom;
 					new_margin = prev_margin + (mm->get_position().y - drag_from.y) / draw_zoom;
 				else if (edited_margin == 1)
 				else if (edited_margin == 1)
@@ -415,6 +415,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
 					new_margin = prev_margin + (mm->get_position().x - drag_from.x) / draw_zoom;
 					new_margin = prev_margin + (mm->get_position().x - drag_from.x) / draw_zoom;
 				else if (edited_margin == 3)
 				else if (edited_margin == 3)
 					new_margin = prev_margin - (mm->get_position().x - drag_from.x) / draw_zoom;
 					new_margin = prev_margin - (mm->get_position().x - drag_from.x) / draw_zoom;
+				else
+					ERR_PRINT("Unexpected edited_margin");
+
 				if (new_margin < 0)
 				if (new_margin < 0)
 					new_margin = 0;
 					new_margin = 0;
 				static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
 				static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };

+ 3 - 3
modules/gdscript/gd_function.cpp

@@ -290,8 +290,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
 
 
 #ifdef DEBUG_ENABLED
 #ifdef DEBUG_ENABLED
 
 
-	uint64_t function_start_time;
-	uint64_t function_call_time;
+	uint64_t function_start_time = 0;
+	uint64_t function_call_time = 0;
 
 
 	if (GDScriptLanguage::get_singleton()->profiling) {
 	if (GDScriptLanguage::get_singleton()->profiling) {
 		function_start_time = OS::get_singleton()->get_ticks_usec();
 		function_start_time = OS::get_singleton()->get_ticks_usec();
@@ -691,7 +691,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
 				}
 				}
 
 
 #ifdef DEBUG_ENABLED
 #ifdef DEBUG_ENABLED
-				uint64_t call_time;
+				uint64_t call_time = 0;
 
 
 				if (GDScriptLanguage::get_singleton()->profiling) {
 				if (GDScriptLanguage::get_singleton()->profiling) {
 					call_time = OS::get_singleton()->get_ticks_usec();
 					call_time = OS::get_singleton()->get_ticks_usec();

+ 5 - 1
modules/squish/image_compress_squish.cpp

@@ -91,7 +91,7 @@ void image_compress_squish(Image *p_image, Image::CompressSource p_source) {
 	if (p_image->get_format() <= Image::FORMAT_RGBA8) {
 	if (p_image->get_format() <= Image::FORMAT_RGBA8) {
 
 
 		int squish_comp = squish::kColourRangeFit;
 		int squish_comp = squish::kColourRangeFit;
-		Image::Format target_format;
+		Image::Format target_format = Image::FORMAT_RGBA8;
 
 
 		Image::DetectChannels dc = p_image->get_detected_channels();
 		Image::DetectChannels dc = p_image->get_detected_channels();
 
 
@@ -140,6 +140,10 @@ void image_compress_squish(Image *p_image, Image::CompressSource p_source) {
 				squish_comp |= squish::kDxt5;
 				squish_comp |= squish::kDxt5;
 
 
 			} break;
 			} break;
+			default: {
+				ERR_PRINT("Unknown image format, defaulting to RGBA8");
+				break;
+			}
 		}
 		}
 
 
 		PoolVector<uint8_t> data;
 		PoolVector<uint8_t> data;

+ 2 - 0
modules/stb_vorbis/audio_stream_ogg_vorbis.cpp

@@ -31,7 +31,9 @@
 
 
 #include "os/file_access.h"
 #include "os/file_access.h"
 
 
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #include "thirdparty/misc/stb_vorbis.c"
 #include "thirdparty/misc/stb_vorbis.c"
+#pragma GCC diagnostic pop
 
 
 void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) {
 void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) {
 
 

+ 2 - 0
modules/stb_vorbis/audio_stream_ogg_vorbis.h

@@ -34,7 +34,9 @@
 #include "servers/audio/audio_stream.h"
 #include "servers/audio/audio_stream.h"
 
 
 #define STB_VORBIS_HEADER_ONLY
 #define STB_VORBIS_HEADER_ONLY
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #include "thirdparty/misc/stb_vorbis.c"
 #include "thirdparty/misc/stb_vorbis.c"
+#pragma GCC diagnostic pop
 #undef STB_VORBIS_HEADER_ONLY
 #undef STB_VORBIS_HEADER_ONLY
 
 
 class AudioStreamOGGVorbis;
 class AudioStreamOGGVorbis;

+ 1 - 1
modules/visual_script/visual_script_yield_nodes.cpp

@@ -516,7 +516,7 @@ public:
 		} else {
 		} else {
 			//yield
 			//yield
 
 
-			Object *object;
+			Object *object = NULL;
 
 
 			switch (call_mode) {
 			switch (call_mode) {
 
 

+ 8 - 8
platform/android/export/export.cpp

@@ -540,14 +540,14 @@ class EditorExportAndroid : public EditorExportPlatform {
 
 
 		//print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));
 		//print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));
 
 
-		uint32_t string_count;
-		uint32_t styles_count;
-		uint32_t string_flags;
-		uint32_t string_data_offset;
-
-		uint32_t styles_offset;
-		uint32_t string_table_begins;
-		uint32_t string_table_ends;
+		uint32_t string_count = 0;
+		uint32_t styles_count = 0;
+		uint32_t string_flags = 0;
+		uint32_t string_data_offset = 0;
+
+		uint32_t styles_offset = 0;
+		uint32_t string_table_begins = 0;
+		uint32_t string_table_ends = 0;
 		Vector<uint8_t> stable_extra;
 		Vector<uint8_t> stable_extra;
 
 
 		String version_name = p_preset->get("version/name");
 		String version_name = p_preset->get("version/name");

+ 3 - 1
platform/uwp/export/export.cpp

@@ -866,7 +866,7 @@ class EditorExportUWP : public EditorExportPlatform {
 	Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
 	Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
 
 
 		Vector<uint8_t> data;
 		Vector<uint8_t> data;
-		StreamTexture *image;
+		StreamTexture *image = NULL;
 
 
 		if (p_path.find("StoreLogo") != -1) {
 		if (p_path.find("StoreLogo") != -1) {
 			image = p_preset->get("images/store_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/store_logo")));
 			image = p_preset->get("images/store_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/store_logo")));
@@ -882,6 +882,8 @@ class EditorExportUWP : public EditorExportPlatform {
 			image = p_preset->get("images/wide310x150_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/wide310x150_logo")));
 			image = p_preset->get("images/wide310x150_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/wide310x150_logo")));
 		} else if (p_path.find("SplashScreen") != -1) {
 		} else if (p_path.find("SplashScreen") != -1) {
 			image = p_preset->get("images/splash_screen").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/splash_screen")));
 			image = p_preset->get("images/splash_screen").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/splash_screen")));
+		} else {
+			ERR_PRINT("Unable to load logo");
 		}
 		}
 
 
 		if (!image) return data;
 		if (!image) return data;

+ 1 - 1
scene/2d/line_builder.cpp

@@ -139,7 +139,7 @@ void LineBuilder::build() {
 
 
 	float current_distance0 = 0.f;
 	float current_distance0 = 0.f;
 	float current_distance1 = 0.f;
 	float current_distance1 = 0.f;
-	float total_distance;
+	float total_distance = 0.f;
 	_interpolate_color = gradient != NULL;
 	_interpolate_color = gradient != NULL;
 	bool distance_required = _interpolate_color || texture_mode == LINE_TEXTURE_TILE;
 	bool distance_required = _interpolate_color || texture_mode == LINE_TEXTURE_TILE;
 	if (distance_required)
 	if (distance_required)

+ 5 - 1
scene/3d/audio_stream_player_3d.cpp

@@ -183,7 +183,7 @@ void AudioStreamPlayer3D::_mix_audio() {
 
 
 float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
 float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
 
 
-	float att;
+	float att = 0;
 	switch (attenuation_model) {
 	switch (attenuation_model) {
 		case ATTENUATION_INVERSE_DISTANCE: {
 		case ATTENUATION_INVERSE_DISTANCE: {
 			att = Math::linear2db(1.0 / ((p_distance / unit_size) + 000001));
 			att = Math::linear2db(1.0 / ((p_distance / unit_size) + 000001));
@@ -196,6 +196,10 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
 		case ATTENUATION_LOGARITHMIC: {
 		case ATTENUATION_LOGARITHMIC: {
 			att = -20 * Math::log(p_distance / unit_size + 000001);
 			att = -20 * Math::log(p_distance / unit_size + 000001);
 		} break;
 		} break;
+		default: {
+			ERR_PRINT("Unknown attenuation type");
+			break;
+		}
 	}
 	}
 
 
 	att += unit_db;
 	att += unit_db;

+ 2 - 2
scene/3d/gi_probe.cpp

@@ -548,8 +548,8 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
 		//plot the face by guessing it's albedo and emission value
 		//plot the face by guessing it's albedo and emission value
 
 
 		//find best axis to map to, for scanning values
 		//find best axis to map to, for scanning values
-		int closest_axis;
-		float closest_dot;
+		int closest_axis = 0;
+		float closest_dot = 0;
 
 
 		Plane plane = Plane(p_vtx[0], p_vtx[1], p_vtx[2]);
 		Plane plane = Plane(p_vtx[0], p_vtx[1], p_vtx[2]);
 		Vector3 normal = plane.normal;
 		Vector3 normal = plane.normal;

+ 1 - 1
scene/gui/label.cpp

@@ -401,7 +401,7 @@ void Label::regenerate_word_cache() {
 		bool separatable = (current >= 0x2E08 && current <= 0xFAFF) || (current >= 0xFE30 && current <= 0xFE4F);
 		bool separatable = (current >= 0x2E08 && current <= 0xFAFF) || (current >= 0xFE30 && current <= 0xFE4F);
 		//current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
 		//current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
 		bool insert_newline = false;
 		bool insert_newline = false;
-		int char_width;
+		int char_width = 0;
 
 
 		if (current < 33) {
 		if (current < 33) {
 
 

+ 1 - 1
scene/gui/text_edit.cpp

@@ -4531,7 +4531,7 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
 		bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
 		bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
 
 
 		bool inside_quotes = false;
 		bool inside_quotes = false;
-		int qbegin, qend;
+		int qbegin = 0, qend = 0;
 		for (int i = 0; i < s.length(); i++) {
 		for (int i = 0; i < s.length(); i++) {
 			if (s[i] == '"') {
 			if (s[i] == '"') {
 				if (inside_quotes) {
 				if (inside_quotes) {

+ 2 - 2
scene/main/viewport.cpp

@@ -491,7 +491,7 @@ void Viewport::_notification(int p_what) {
 			if (physics_object_picking && (to_screen_rect == Rect2() || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) {
 			if (physics_object_picking && (to_screen_rect == Rect2() || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) {
 
 
 				Vector2 last_pos(1e20, 1e20);
 				Vector2 last_pos(1e20, 1e20);
-				CollisionObject *last_object;
+				CollisionObject *last_object = NULL;
 				ObjectID last_id = 0;
 				ObjectID last_id = 0;
 				PhysicsDirectSpaceState::RayResult result;
 				PhysicsDirectSpaceState::RayResult result;
 				Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
 				Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
@@ -604,7 +604,7 @@ void Viewport::_notification(int p_what) {
 					} else if (pos == last_pos) {
 					} else if (pos == last_pos) {
 
 
 						if (last_id) {
 						if (last_id) {
-							if (ObjectDB::get_instance(last_id)) {
+							if (ObjectDB::get_instance(last_id) && last_object) {
 								//good, exists
 								//good, exists
 								last_object->_input_event(camera, ev, result.position, result.normal, result.shape);
 								last_object->_input_event(camera, ev, result.position, result.normal, result.shape);
 								if (last_object->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
 								if (last_object->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {

+ 8 - 3
scene/resources/animation.cpp

@@ -970,7 +970,12 @@ int Animation::_find(const Vector<K> &p_keys, float p_time) const {
 
 
 	int low = 0;
 	int low = 0;
 	int high = len - 1;
 	int high = len - 1;
-	int middle;
+	int middle = 0;
+
+#if DEBUG_ENABLED
+	if (low > high)
+		ERR_PRINT("low > high, this may be a bug");
+#endif
 
 
 	const K *keys = &p_keys[0];
 	const K *keys = &p_keys[0];
 
 
@@ -1289,7 +1294,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
 
 
 	TransformTrack *tt = static_cast<TransformTrack *>(t);
 	TransformTrack *tt = static_cast<TransformTrack *>(t);
 
 
-	bool ok;
+	bool ok = false;
 
 
 	TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok);
 	TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok);
 
 
@@ -1315,7 +1320,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
 	ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
 	ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
 	ValueTrack *vt = static_cast<ValueTrack *>(t);
 	ValueTrack *vt = static_cast<ValueTrack *>(t);
 
 
-	bool ok;
+	bool ok = false;
 
 
 	Variant res = _interpolate(vt->values, p_time, vt->update_mode == UPDATE_CONTINUOUS ? vt->interpolation : INTERPOLATION_NEAREST, vt->loop_wrap, &ok);
 	Variant res = _interpolate(vt->values, p_time, vt->update_mode == UPDATE_CONTINUOUS ? vt->interpolation : INTERPOLATION_NEAREST, vt->loop_wrap, &ok);
 
 

+ 6 - 1
scene/resources/color_ramp.h

@@ -88,7 +88,12 @@ public:
 		//binary search
 		//binary search
 		int low = 0;
 		int low = 0;
 		int high = points.size() - 1;
 		int high = points.size() - 1;
-		int middle;
+		int middle = 0;
+
+#if DEBUG_ENABLED
+		if (low > high)
+			ERR_PRINT("low > high, this may be a bug");
+#endif
 
 
 		while (low <= high) {
 		while (low <= high) {
 			middle = (low + high) / 2;
 			middle = (low + high) / 2;

+ 4 - 1
scene/resources/font.cpp

@@ -40,7 +40,7 @@ void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, f
 		return;
 		return;
 	}
 	}
 
 
-	float ofs;
+	float ofs = 0.f;
 	switch (p_align) {
 	switch (p_align) {
 		case HALIGN_LEFT: {
 		case HALIGN_LEFT: {
 			ofs = 0;
 			ofs = 0;
@@ -51,6 +51,9 @@ void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, f
 		case HALIGN_RIGHT: {
 		case HALIGN_RIGHT: {
 			ofs = p_width - length;
 			ofs = p_width - length;
 		} break;
 		} break;
+		default: {
+			ERR_PRINT("Unknown halignment type");
+		} break;
 	}
 	}
 	draw(p_canvas_item, p_pos + Point2(ofs, 0), p_text, p_modulate, p_width);
 	draw(p_canvas_item, p_pos + Point2(ofs, 0), p_text, p_modulate, p_width);
 }
 }

+ 1 - 1
servers/physics/collision_solver_sw.cpp

@@ -271,7 +271,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra
 
 
 	bool collided = false;
 	bool collided = false;
 	Vector3 closest;
 	Vector3 closest;
-	real_t closest_d;
+	real_t closest_d = 0;
 
 
 	for (int i = 0; i < support_count; i++) {
 	for (int i = 0; i < support_count; i++) {
 
 

+ 3 - 3
servers/physics/gjk_epa.cpp

@@ -410,8 +410,8 @@ struct	GJK
 			if(l>GJK_SIMPLEX3_EPS)
 			if(l>GJK_SIMPLEX3_EPS)
 			{
 			{
 				real_t	mindist=-1;
 				real_t	mindist=-1;
-				real_t	subw[2];
-				U			subm;
+				real_t	subw[2] = { 0 , 0};
+				U 		subm = 0;
 				for(U i=0;i<3;++i)
 				for(U i=0;i<3;++i)
 				{
 				{
 					if(vec3_dot(*vt[i],vec3_cross(dl[i],n))>0)
 					if(vec3_dot(*vt[i],vec3_cross(dl[i],n))>0)
@@ -458,7 +458,7 @@ struct	GJK
 			{
 			{
 				real_t	mindist=-1;
 				real_t	mindist=-1;
 				real_t	subw[3];
 				real_t	subw[3];
-				U			subm;
+				U		subm=0;
 				for(U i=0;i<3;++i)
 				for(U i=0;i<3;++i)
 				{
 				{
 					const U			j=imd3[i];
 					const U			j=imd3[i];

+ 5 - 5
servers/physics/shape_sw.cpp

@@ -734,7 +734,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3 &p_normal) const {
 	Vector3 n = p_normal;
 	Vector3 n = p_normal;
 
 
 	int vert_support_idx = -1;
 	int vert_support_idx = -1;
-	real_t support_max;
+	real_t support_max = 0;
 
 
 	int vertex_count = mesh.vertices.size();
 	int vertex_count = mesh.vertices.size();
 	if (vertex_count == 0)
 	if (vertex_count == 0)
@@ -767,8 +767,8 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect
 	int vc = mesh.vertices.size();
 	int vc = mesh.vertices.size();
 
 
 	//find vertex first
 	//find vertex first
-	real_t max;
-	int vtx;
+	real_t max = 0;
+	int vtx = 0;
 
 
 	for (int i = 0; i < vc; i++) {
 	for (int i = 0; i < vc; i++) {
 
 
@@ -1000,7 +1000,7 @@ void FaceShapeSW::project_range(const Vector3 &p_normal, const Transform &p_tran
 Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const {
 Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const {
 
 
 	int vert_support_idx = -1;
 	int vert_support_idx = -1;
-	real_t support_max;
+	real_t support_max = 0;
 
 
 	for (int i = 0; i < 3; i++) {
 	for (int i = 0; i < 3; i++) {
 
 
@@ -1154,7 +1154,7 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3 &p_normal) const {
 	Vector3 n = p_normal;
 	Vector3 n = p_normal;
 
 
 	int vert_support_idx = -1;
 	int vert_support_idx = -1;
-	real_t support_max;
+	real_t support_max = 0;
 
 
 	for (int i = 0; i < count; i++) {
 	for (int i = 0; i < count; i++) {
 
 

+ 1 - 1
servers/visual/shader_language.cpp

@@ -2586,7 +2586,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
 				}
 				}
 
 
 				bool index_valid = false;
 				bool index_valid = false;
-				DataType member_type;
+				DataType member_type = TYPE_VOID;
 
 
 				switch (expr->get_datatype()) {
 				switch (expr->get_datatype()) {
 					case TYPE_BVEC2:
 					case TYPE_BVEC2:

+ 7 - 7
servers/visual/visual_server_scene.cpp

@@ -948,13 +948,13 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
 				Vector3 z_vec = transform.basis.get_axis(Vector3::AXIS_Z).normalized();
 				Vector3 z_vec = transform.basis.get_axis(Vector3::AXIS_Z).normalized();
 				//z_vec points agsint the camera, like in default opengl
 				//z_vec points agsint the camera, like in default opengl
 
 
-				float x_min, x_max;
-				float y_min, y_max;
-				float z_min, z_max;
+				float x_min = 0.f, x_max = 0.f;
+				float y_min = 0.f, y_max = 0.f;
+				float z_min = 0.f, z_max = 0.f;
 
 
-				float x_min_cam, x_max_cam;
-				float y_min_cam, y_max_cam;
-				float z_min_cam, z_max_cam;
+				float x_min_cam = 0.f, x_max_cam = 0.f;
+				float y_min_cam = 0.f, y_max_cam = 0.f;
+				float z_min_cam = 0.f, z_max_cam = 0.f;
 
 
 				float bias_scale = 1.0;
 				float bias_scale = 1.0;
 
 
@@ -1503,7 +1503,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
 
 
 			InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
 			InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
 
 
-			float coverage;
+			float coverage = 0.f;
 
 
 			{ //compute coverage
 			{ //compute coverage