dinput: Fix incorrect check in device_disabled_registry.

Gerald Pfeifer gerald at pfeifer.com
Fri Aug 24 19:18:14 CDT 2012


disabled_str is defined as
  static const char *disabled_str = "disabled";

sizeof for disabled_str thus is not what we want here when invoking
strncmp, since this is really about the length of the string, not the
size of the pointer type.

The first patch is the straightforward one; the second the one I'd
recommend.

Gerald

---
 dlls/dinput/joystick.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 0f7ba19..daab390 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -75,7 +75,7 @@ BOOL device_disabled_registry(const char* name)
 
     /* Look for the "controllername"="disabled" key */
     if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
-        if (!strncmp(disabled_str, buffer, sizeof(disabled_str)))
+        if (!strncmp(disabled_str, buffer, strlen(disabled_str)))
         {
             TRACE("Disabling joystick '%s' based on registry key.\n", name);
             do_disable = TRUE;
-- 
1.7.11.1


diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 0f7ba19..181649e 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -51,8 +51,8 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener
 
 BOOL device_disabled_registry(const char* name)
 {
-    static const char *disabled_str = "disabled";
-    static const char *joystick_key = "Joysticks";
+    static const char disabled_str[] = "disabled";
+    static const char joystick_key[] = "Joysticks";
     char buffer[MAX_PATH];
     HKEY hkey, appkey, temp;
     BOOL do_disable = FALSE;



More information about the wine-patches mailing list