From 73bf2ebeaac2f385e98b38975ecc4907881a1743 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Mon, 2 Dec 2024 17:56:30 +0100 Subject: [PATCH 1/2] Fix array size computation This fixes an array size computation that assumed that the array elements are char * when in fact they are char arrays. --- Descent3/CtlCfgElem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index 3d988572..a8ad16a9 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -392,7 +392,7 @@ static int16_t key_binding_indices[] = { KEY_PADPERIOD, KEY_PADENTER, KEY_RCTRL, KEY_PADDIVIDE, KEY_RALT, KEY_HOME, KEY_UP, KEY_PAGEUP, KEY_LEFT, KEY_RIGHT, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0xff}; -#define NUM_KEYBINDSTRINGS (sizeof(Ctltext_KeyBindings) / sizeof(char *)) +#define NUM_KEYBINDSTRINGS (sizeof(Ctltext_KeyBindings) / sizeof(Ctltext_KeyBindings[0])) #define F_ELEM_HILITE 0x1 #define F_ELEM_ACTIVE 0x2 From 8ffbc6c5eafdf7c8019d013bd04da04d1709fe9b Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Mon, 2 Dec 2024 18:01:00 +0100 Subject: [PATCH 2/2] Fix array size computation This fixes an array size computation that assumed that the array elements are char * when in fact they are char arrays. --- ddio/lnxmouse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddio/lnxmouse.cpp b/ddio/lnxmouse.cpp index 558d2519..f2fc6806 100644 --- a/ddio/lnxmouse.cpp +++ b/ddio/lnxmouse.cpp @@ -537,7 +537,7 @@ const char *ddio_MouseGetBtnText(int btn) { } const char *ddio_MouseGetAxisText(int axis) { - if (axis >= (sizeof(Ctltext_MseAxisBindings) / sizeof(char *)) || axis < 0) + if (axis >= static_cast(sizeof(Ctltext_MseAxisBindings) / sizeof(Ctltext_MseAxisBindings[0])) || axis < 0) return (""); return Ctltext_MseAxisBindings[axis]; }