diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 15:06:57 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 19:49:50 +0200 |
commit | f8ab79e68af20e18e1d868b64d6dfd0c429bc554 (patch) | |
tree | a9d2df2e2df939c189135b1c36a01e06b37b80b2 /core/io | |
parent | 53317bbe146dd19a919685df8d846c55568daba1 (diff) |
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.
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/file_access.h | 2 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 6 | ||||
-rw-r--r-- | core/io/ip.h | 2 | ||||
-rw-r--r-- | core/io/resource_format_binary.h | 2 | ||||
-rw-r--r-- | core/io/resource_uid.h | 2 | ||||
-rw-r--r-- | core/io/udp_server.h | 2 |
6 files changed, 8 insertions, 8 deletions
diff --git a/core/io/file_access.h b/core/io/file_access.h index a6cb5d9fc6..a5150010da 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -183,7 +183,7 @@ struct FileAccessRef { operator bool() const { return f != nullptr; } - FileAccess *f; + FileAccess *f = nullptr; operator FileAccess *() { return f; } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 6eee2f593d..fe4b12aef6 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -64,7 +64,7 @@ public: uint64_t offset; //if offset is ZERO, the file was ERASED uint64_t size; uint8_t md5[16]; - PackSource *src; + PackSource *src = nullptr; bool encrypted; }; @@ -103,7 +103,7 @@ private: Vector<PackSource *> sources; - PackedDir *root; + PackedDir *root = nullptr; static PackedData *singleton; bool disabled = false; @@ -150,7 +150,7 @@ class FileAccessPack : public FileAccess { mutable bool eof; uint64_t off; - FileAccess *f; + FileAccess *f = nullptr; virtual Error _open(const String &p_path, int p_mode_flags); virtual uint64_t _get_modified_time(const String &p_file) { return 0; } virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } diff --git a/core/io/ip.h b/core/io/ip.h index ebd944a949..06ff8a4d70 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -62,7 +62,7 @@ public: typedef int ResolverID; private: - _IP_ResolverPrivate *resolver; + _IP_ResolverPrivate *resolver = nullptr; protected: static IP *singleton; diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index c80c9b0ac9..5403168a53 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -127,7 +127,7 @@ class ResourceFormatSaverBinaryInstance { bool skip_editor; bool big_endian; bool takeover_paths; - FileAccess *f; + FileAccess *f = nullptr; String magic; Set<RES> resource_set; diff --git a/core/io/resource_uid.h b/core/io/resource_uid.h index 1ea44b9d06..0b7ffdf6d0 100644 --- a/core/io/resource_uid.h +++ b/core/io/resource_uid.h @@ -46,7 +46,7 @@ public: static String get_cache_file(); private: - void *crypto; // CryptoCore::RandomGenerator (avoid including crypto_core.h) + void *crypto = nullptr; // CryptoCore::RandomGenerator (avoid including crypto_core.h) Mutex mutex; struct Cache { CharString cs; diff --git a/core/io/udp_server.h b/core/io/udp_server.h index 4a7546fddf..47f06b2490 100644 --- a/core/io/udp_server.h +++ b/core/io/udp_server.h @@ -43,7 +43,7 @@ protected: }; struct Peer { - PacketPeerUDP *peer; + PacketPeerUDP *peer = nullptr; IPAddress ip; uint16_t port = 0; |