From 107dfc4203b85dbbf2e6acc5fec3db1dfc5e9057 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 00:57:54 -0400 Subject: [PATCH 1/2] PAK: Zero initialize m_sz and m_pos of PAKEntryReadStream Provides a deterministic initial state for the members in the case of the default constructor. --- DataSpec/DNACommon/PAK.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 39d1a6c5e..66267e5c7 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -18,11 +18,11 @@ namespace DataSpec { /** PAK entry stream reader */ class PAKEntryReadStream : public athena::io::IStreamReader { std::unique_ptr m_buf; - atUint64 m_sz; - atUint64 m_pos; + atUint64 m_sz = 0; + atUint64 m_pos = 0; public: - PAKEntryReadStream() {} + PAKEntryReadStream() = default; operator bool() const { return m_buf.operator bool(); } PAKEntryReadStream(const PAKEntryReadStream& other) = delete; PAKEntryReadStream(PAKEntryReadStream&& other) = default; From 7a0e7f449e63065e1787ceabb34f89411fb8a1b6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 00:59:29 -0400 Subject: [PATCH 2/2] PAK: Make operator bool() explicit for PAKEntryReadStream Prevents potential error-prone conversions to bool. --- DataSpec/DNACommon/PAK.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 66267e5c7..f4ef94012 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -23,7 +23,7 @@ class PAKEntryReadStream : public athena::io::IStreamReader { public: PAKEntryReadStream() = default; - operator bool() const { return m_buf.operator bool(); } + explicit operator bool() const { return m_buf.operator bool(); } PAKEntryReadStream(const PAKEntryReadStream& other) = delete; PAKEntryReadStream(PAKEntryReadStream&& other) = default; PAKEntryReadStream& operator=(const PAKEntryReadStream& other) = delete;