From f7a6b2d90abb9fa7e16e2a67235cedb2edddc42b Mon Sep 17 00:00:00 2001 From: BayernMuller Date: Thu, 19 Dec 2024 09:23:28 +0900 Subject: [PATCH] fix: initialize struct and variables properly --- lib/algorithm/signature.cpp | 2 +- lib/utils/crc32.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/algorithm/signature.cpp b/lib/algorithm/signature.cpp index 6e010a1..bdbc513 100644 --- a/lib/algorithm/signature.cpp +++ b/lib/algorithm/signature.cpp @@ -29,7 +29,7 @@ std::uint32_t Signature::SumOfPeaksLength() const std::string Signature::EncodeBase64() const { - RawSignatureHeader header; + RawSignatureHeader header = {0}; header.magic1 = 0xcafe2580; header.magic2 = 0x94119c00; header.shifted_sample_rate_id = 3 << 27; diff --git a/lib/utils/crc32.h b/lib/utils/crc32.h index 1f38fe5..3c0be71 100644 --- a/lib/utils/crc32.h +++ b/lib/utils/crc32.h @@ -5,9 +5,10 @@ namespace crc32 { std::uint32_t crc32(const char *buf, std::size_t len) { - std::uint32_t crc_table[256]; - std::uint32_t crc; - std::size_t i, j; + std::uint32_t crc_table[256] = {0}; + std::uint32_t crc = 0; + std::size_t i = 0; + std::size_t j = 0; for (i = 0; i < 256; i++) {