From f8ab79e68af20e18e1d868b64d6dfd0c429bc554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 4 Apr 2022 15:06:57 +0200 Subject: Zero initialize all pointer class and struct members This prevents the pitfall of UB when checking if they have been assigned something valid by comparing to nullptr. --- drivers/gles3/rasterizer_canvas_gles3.h | 8 ++++---- drivers/gles3/storage/material_storage.h | 4 ++-- drivers/gles3/storage/texture_storage.h | 10 +++++----- drivers/unix/dir_access_unix.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 4e825ab8b2..70066c5e2a 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -169,7 +169,7 @@ public: LocalVector fences; uint32_t current_buffer = 0; - InstanceData *instance_data_array; + InstanceData *instance_data_array = nullptr; bool canvas_texscreen_used; CanvasShaderGLES3 canvas_shader; RID canvas_shader_current_version; @@ -198,7 +198,7 @@ public: bool end_batch = false; Transform3D vp; - Light *using_light; + Light *using_light = nullptr; bool using_shadow; bool using_transparent_rt; @@ -220,9 +220,9 @@ public: typedef void Texture; - RasterizerSceneGLES3 *scene_render; + RasterizerSceneGLES3 *scene_render = nullptr; - RasterizerStorageGLES3 *storage; + RasterizerStorageGLES3 *storage = nullptr; void _set_uniforms(); diff --git a/drivers/gles3/storage/material_storage.h b/drivers/gles3/storage/material_storage.h index bf17e66c2f..450ee7191f 100644 --- a/drivers/gles3/storage/material_storage.h +++ b/drivers/gles3/storage/material_storage.h @@ -66,7 +66,7 @@ struct Shader { RID self; RS::ShaderMode mode; - ShaderGLES3 *shader; + ShaderGLES3 *shader = nullptr; String code; SelfList::List materials; @@ -185,7 +185,7 @@ struct Shader { struct Material { RID self; - Shader *shader; + Shader *shader = nullptr; Map params; SelfList list; SelfList dirty_list; diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 8a921fbe10..7656cdf67e 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -93,7 +93,7 @@ enum OpenGLTextureFlags { struct Texture { RID self; - Texture *proxy; + Texture *proxy = nullptr; Set proxy_owners; String path; @@ -125,20 +125,20 @@ struct Texture { uint16_t stored_cube_sides; - RenderTarget *render_target; + RenderTarget *render_target = nullptr; Vector> images; bool redraw_if_visible; RS::TextureDetectCallback detect_3d; - void *detect_3d_ud; + void *detect_3d_ud = nullptr; RS::TextureDetectCallback detect_srgb; - void *detect_srgb_ud; + void *detect_srgb_ud = nullptr; RS::TextureDetectCallback detect_normal; - void *detect_normal_ud; + void *detect_normal_ud = nullptr; CanvasTexture *canvas_texture = nullptr; diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index f90f55605c..b4dc012db2 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -41,7 +41,7 @@ #include class DirAccessUnix : public DirAccess { - DIR *dir_stream; + DIR *dir_stream = nullptr; static DirAccess *create_fs(); -- cgit v1.2.3