Browse Source

Initialise scandir argument

'scandir' does not initialise 'entries' on error
Mathieu Eyraud 3 years ago
parent
commit
99ae6395b1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/joystick/linux/SDL_sysjoystick.c

+ 2 - 2
src/joystick/linux/SDL_sysjoystick.c

@@ -610,7 +610,7 @@ static int get_event_joystick_index(int event)
 {
     int joystick_index = -1;
     int i, count;
-    struct dirent **entries;
+    struct dirent **entries = NULL;
     char path[PATH_MAX];
 
     SDL_snprintf(path, SDL_arraysize(path), "/sys/class/input/event%d/device", event);
@@ -679,7 +679,7 @@ LINUX_FallbackJoystickDetect(void)
         /* Opening input devices can generate synchronous device I/O, so avoid it if we can */
         if (stat("/dev/input", &sb) == 0 && sb.st_mtime != last_input_dir_mtime) {
             int i, count;
-            struct dirent **entries;
+            struct dirent **entries = NULL;
             char path[PATH_MAX];
 
             count = scandir("/dev/input", &entries, filter_entries, sort_entries);