old-knossos icon indicating copy to clipboard operation
old-knossos copied to clipboard

joystick indexing bug

Open Goober5000 opened this issue 4 years ago • 2 comments

This was spotted by qazwsxal on Discord. This is in runner.py, lines 216-222:

                elif len(candidates) == 0:
                    if len(flags['joysticks']) > sel_id:
                        logging.warning('Mapping joystick %s => %s (based on index)', sel_guid, candidates[sel_id]['guid'])

                        cfg['fso']['joystick_guid'] = candidates[sel_id]['guid']
                    else:
                        logging.error('Joystick mapping failed!')

Notice that the code is indexing into a proven zero-length array.

Goober5000 avatar Oct 15 '20 16:10 Goober5000

I can't really tell if the 0-length check is correct and the code is wrong, or if the test should be != 0 instead. I lean toward it should be != 0, but someone more knowledgeable with the code should check.

Goober5000 avatar Oct 15 '20 17:10 Goober5000

Yeah, I (or someone) will need to do some digging to figure out what ngld was trying to do here.

jg18 avatar Oct 20 '20 05:10 jg18