diff --git a/srtcore/strerror_defs.cpp b/srtcore/strerror_defs.cpp index 7393c1279..1b4c72e4e 100644 --- a/srtcore/strerror_defs.cpp +++ b/srtcore/strerror_defs.cpp @@ -140,7 +140,7 @@ const char* strerror_get_message(size_t major, size_t minor) } const char** array = strerror_array_major[major]; - size_t size = strerror_array_sizes[major]; + const size_t size = strerror_array_sizes[major]; if (minor >= size) { diff --git a/srtcore/utilities.h b/srtcore/utilities.h index 1610505b8..241046ddc 100644 --- a/srtcore/utilities.h +++ b/srtcore/utilities.h @@ -44,6 +44,7 @@ written by #include #include #include +#include // -------------- UTILITIES ------------------------ @@ -418,7 +419,8 @@ class FixedArray { public: FixedArray(size_t size) - : m_size(size) + : m_strIndexErr("FixedArray: invalid index") + , m_size(size) , m_entries(new T[size]) { } @@ -432,7 +434,7 @@ class FixedArray const T& operator[](size_t index) const { if (index >= m_size) - throw std::runtime_error("Invalid index"); + throw std::runtime_error(m_strIndexErr); return m_entries[index]; } @@ -440,7 +442,7 @@ class FixedArray T& operator[](size_t index) { if (index >= m_size) - throw std::runtime_error("Invalid index"); + throw std::runtime_error(m_strIndexErr); return m_entries[index]; } @@ -448,7 +450,7 @@ class FixedArray const T& operator[](int index) const { if (index < 0 || static_cast(index) >= m_size) - throw std::runtime_error("Invalid index"); + throw std::runtime_error(m_strIndexErr); return m_entries[index]; } @@ -456,7 +458,7 @@ class FixedArray T& operator[](int index) { if (index < 0 || static_cast(index) >= m_size) - throw std::runtime_error("Invalid index"); + throw std::runtime_error(m_strIndexErr); return m_entries[index]; } @@ -468,8 +470,9 @@ class FixedArray FixedArray& operator=(const FixedArray&); private: - size_t m_size; - T* const m_entries; + const char* m_strIndexErr; + size_t m_size; + T* const m_entries; }; } // namespace srt