Merge pull request #2280 from ergo720/log_fix

Fixed insufficient size of LoggedModules variable
This commit is contained in:
Luke Usher 2021-09-06 16:48:47 +01:00 committed by GitHub
commit ac68fd481c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -58,7 +58,7 @@ typedef enum _CXBX_DATA {
// ******************************************************************
// * Define number of integers required to store logging settings
// ******************************************************************
#define NUM_INTEGERS_LOG 2
#define NUM_INTEGERS_LOG 3
enum {
LLE_NONE = 0,
@ -109,7 +109,7 @@ public:
bool Reserved4 = 0;
int Reserved99[10] = { 0 };
} m_core;
static_assert(sizeof(s_core) == 0x24C, assert_check_shared_memory(s_core));
static_assert(sizeof(s_core) == 0x250, assert_check_shared_memory(s_core));
// Video settings
struct s_video {

View File

@ -30,6 +30,9 @@
#include "common\IPCHybrid.hpp"
// Sanity check: ensure that NUM_INTEGERS_LOG is large enough to hold all our logging modules
static_assert(to_underlying(CXBXR_MODULE::MAX) <= sizeof(unsigned int) * CHAR_BIT * NUM_INTEGERS_LOG);
static bool g_bHasChanges = false;
static HWND g_ChildWnd = NULL;
INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -128,8 +131,9 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
// Set window icon
SetClassLong(hWndDlg, GCL_HICON, (LONG)LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_CXBX)));
LoggedModules[0] = g_Settings->m_core.LoggedModules[0];
LoggedModules[1] = g_Settings->m_core.LoggedModules[1];
for (unsigned i = 0; i < NUM_INTEGERS_LOG; ++i) {
LoggedModules[i] = g_Settings->m_core.LoggedModules[i];
}
LogLevel = g_Settings->m_core.LogLevel;
LogPopupTestCase = g_Settings->m_core.bLogPopupTestCase;
@ -246,8 +250,9 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
LogPopupTestCase = true;
}
g_Settings->m_core.LoggedModules[0] = LoggedModules[0];
g_Settings->m_core.LoggedModules[1] = LoggedModules[1];
for (unsigned i = 0; i < NUM_INTEGERS_LOG; ++i) {
g_Settings->m_core.LoggedModules[i] = LoggedModules[i];
}
g_Settings->m_core.LogLevel = LogLevel;
g_Settings->m_core.bLogPopupTestCase = LogPopupTestCase;