File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
vice/src/arch/gtk3/joystickdrv Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -649,12 +649,14 @@ void joystick_arch_init(void)
649649 /* scan axes, buttons and hats */
650650 if (scan_inputs (joydev )) {
651651 /* OK: try to register */
652+ char * backup_name = lib_strdup (joydev -> name );
653+
652654 if (!joystick_device_register (joydev )) {
653655 /* failure */
656+ /* joydev is already destroyed */
654657 log_warning (bsd_joy_log ,
655658 "failed to register device %s (\"%s\")" ,
656- joydev -> node , joydev -> name );
657- joystick_device_free (joydev );
659+ node , backup_name );
658660 } else {
659661 priv = joydev -> priv ;
660662 /* allocate arrays for previous input states */
@@ -665,6 +667,7 @@ void joystick_arch_init(void)
665667 priv -> prev_hats = lib_calloc ((size_t )joydev -> num_hats ,
666668 sizeof * priv -> prev_hats );
667669 }
670+ lib_free (backup_name );
668671 } else {
669672 /* failure while scanning: log and free invalid device */
670673 log_warning (bsd_joy_log ,
You can’t perform that action at this time.
0 commit comments