Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2015-08-01 13:38:22 +0300
committerUnderground78 <underground78@users.sourceforge.net>2015-08-01 16:03:36 +0300
commit00a042fd7fa38c3313e6e44da4ebfb8dec677cd2 (patch)
tree6a2e067bc3834e0bab1a6e7daffe8adc4f63dc1c
parent92dfbf2dc3e5f9ae931a064756208face829c017 (diff)
Add a static assert to guard potentially dangerous code.
As long as the structure is packed on 4 bytes, the shortcut we use is safe.
-rw-r--r--src/Subtitles/VobSubFile.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp
index f1f8e33be..5aea79665 100644
--- a/src/Subtitles/VobSubFile.cpp
+++ b/src/Subtitles/VobSubFile.cpp
@@ -598,6 +598,8 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
}
m_nLang = (iLang < 0 && size_t(iLang) >= m_langs.size()) ? SIZE_T_ERROR : size_t(iLang);
} else if (entry == _T("palette")) {
+ // The assert guarantees that the shortcut we use will work as expected
+ static_assert(sizeof(RGBQUAD) == 4, "Packing error");
if (_stscanf_s(str, _T("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x"),
&m_orgpal[0], &m_orgpal[1], &m_orgpal[2], &m_orgpal[3],
&m_orgpal[4], &m_orgpal[5], &m_orgpal[6], &m_orgpal[7],