]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added checks for the array index code in hid.c.
authoryellows8 <yellows8@users.noreply.github.com>
Wed, 27 Aug 2014 21:42:53 +0000 (17:42 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Wed, 27 Aug 2014 21:42:53 +0000 (17:42 -0400)
libctru/source/services/hid.c

index e67e60dab3e4ccb85cb8589a5f6150072da5c88b..1265ec9dc088e8319d8e2f5abc0c7c79a7194655 100644 (file)
@@ -53,11 +53,13 @@ void hidScanInput()
 {
        kOld = kHeld;
 
-       int padId = hidSharedMem[4];
+       u32 padId = hidSharedMem[4];
+       if(padId>7)padId=7;
        kHeld = hidSharedMem[10 + padId*4];
        cPos = *(circlePosition*)&hidSharedMem[10 + padId*4 + 3];
 
-       int touchId = hidSharedMem[42 + 4];
+       u32 touchId = hidSharedMem[42 + 4];
+       if(touchId>7)touchId=7;
        tPos = *(touchPosition*)&hidSharedMem[42 + 8 + touchId*2];
        if (hidSharedMem[42 + 8 + touchId*2 + 1])
                kHeld |= KEY_TOUCH;