Skip to content

Commit 274d03b

Browse files
committed
src/keycode: fix buffer overflow
At https://github.com/octalmage/robotjs/blob/b26c7ee0e3dd05420370350e540c48ae9d38f06c/src/keycode.c#L98, `sizeof(void*)` bytes (probably 8) are written to a memory segment of 2 bytes (a 16-bit CGKeycode variable), resulting in all kinds of weird behaviour, like unrelated variables getting NULLed. Making `code` a a type that can hold `sizeof(void*)` bytes fixes this. Closes #570
1 parent 603de61 commit 274d03b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/keycode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ MMKeyCode keyCodeForChar(const char c)
6868
/* OS X does not appear to have a built-in function for this, so instead we
6969
* have to write our own. */
7070
static CFMutableDictionaryRef charToCodeDict = NULL;
71-
CGKeyCode code;
71+
size_t code;
7272
UniChar character = c;
7373
CFStringRef charStr = NULL;
7474

0 commit comments

Comments
 (0)