shortcut_catcher: fixed out of bounds access and a sign warning.
* normal_map is an array with a length of 128
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
|
|
||||||
#define NUM_KEYS 256
|
#define NUM_KEYS 128
|
||||||
#define MAX_UTF8_LENGTH 5 // up to 4 chars, plus a nul terminator
|
#define MAX_UTF8_LENGTH 5 // up to 4 chars, plus a nul terminator
|
||||||
|
|
||||||
struct KeyLabelMap {
|
struct KeyLabelMap {
|
||||||
@@ -97,10 +97,8 @@ static const char* keyDescriptions[NUM_KEYS];
|
|||||||
// series of optional up-to-(4+1)-byte terminated UTF-8 character strings...
|
// series of optional up-to-(4+1)-byte terminated UTF-8 character strings...
|
||||||
static char utfDescriptions[NUM_KEYS * MAX_UTF8_LENGTH];
|
static char utfDescriptions[NUM_KEYS * MAX_UTF8_LENGTH];
|
||||||
|
|
||||||
static const char* FindSpecialKeyLabelFor(uint8 keyCode, int& last);
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
FindSpecialKeyLabelFor(uint8 keyCode, int& last)
|
FindSpecialKeyLabelFor(uint8 keyCode, uint32& last)
|
||||||
{
|
{
|
||||||
while ((keyLabels[last].fKeyCode < keyCode)
|
while ((keyLabels[last].fKeyCode < keyCode)
|
||||||
&& (last < (sizeof(keyLabels) / sizeof(struct KeyLabelMap)) - 1))
|
&& (last < (sizeof(keyLabels) / sizeof(struct KeyLabelMap)) - 1))
|
||||||
@@ -116,7 +114,7 @@ FindSpecialKeyLabelFor(uint8 keyCode, int& last)
|
|||||||
void
|
void
|
||||||
InitKeyIndices()
|
InitKeyIndices()
|
||||||
{
|
{
|
||||||
int nextSpecial = 0;
|
uint32 nextSpecial = 0;
|
||||||
key_map* map;
|
key_map* map;
|
||||||
char* keys;
|
char* keys;
|
||||||
get_key_map(&map, &keys);
|
get_key_map(&map, &keys);
|
||||||
@@ -125,8 +123,8 @@ InitKeyIndices()
|
|||||||
keyDescriptions[j] = NULL; // default
|
keyDescriptions[j] = NULL; // default
|
||||||
|
|
||||||
const char* slabel = FindSpecialKeyLabelFor(j, nextSpecial);
|
const char* slabel = FindSpecialKeyLabelFor(j, nextSpecial);
|
||||||
int keyCode = map->normal_map[j];
|
int32 keyCode = map->normal_map[j];
|
||||||
|
|
||||||
if (keyCode >= 0) {
|
if (keyCode >= 0) {
|
||||||
const char* mapDesc = &keys[keyCode];
|
const char* mapDesc = &keys[keyCode];
|
||||||
uint8 len = *mapDesc;
|
uint8 len = *mapDesc;
|
||||||
|
|||||||
Reference in New Issue
Block a user