Re: [hatari-devel] Joystick dialog crashes with Ubuntu 24.04 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Joystick dialog crashes with Ubuntu 24.04
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Sat, 6 Jul 2024 06:05:03 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1720245905; bh=Npp+fxMPMXVPn4eDEAFydlW/fLgcosM1Imk+hjT2uHk=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=gYVXb54ISVryqfoGTkCUKrMms9x0aE8n90psH84dWzaEG6Uge8ic29PHD3hJL191F YyD9dqRFwTT/nmqAipURAKjB9j6PfTfpy/upABx6XnGdJByQq3tMvJtjGNnVU2N5+k VZFzSvs/3m1K7EWuujilcwV6B5QW73cRUx+geUUEk6Rq+PfVNlFTL5NkzHqTOXfpF3 maW7K6DhE9UJc3MolxX5LD2QyDdV2+UJwYlclMYh+4mR2884onwCGj92xx+NvJT5DR P+sMkcjOnpg6novCW/9iZoqqV2yEHlRidZS9aRopPNTiBtTdr9BxqL05cQ3+CLcTUV oG/uHY0AtuStw==
Am Fri, 5 Jul 2024 17:00:06 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
> Hi,
>
> User is reporting that opening SDL GUI Joystick dialog crashes Hatari,
> on Lubuntu 24.04:
> https://www.atari-forum.com/viewtopic.php?p=466100
>
> Is anybody here using some Ubuntu 24.04 variant? And if yes, can you
> reproduce the issue?
>
>
> I took a quick look at the related code, and it's possible that SDL
> Joystick name query may get given invalid struct address if SDL reports
> error or no joysticks, or user has invalid joystick mapping in his
> config file.
>
> Attached patch will hopefully handle such issues. Any comments on it?
/**
- * Return maximum available real joystick ID
+ * Return maximum available real joystick ID, or
+ * zero on error or no joystick (to avoid invalid array accesses)
*/
int Joy_GetMaxId(void)
{
int count = SDL_NumJoysticks();
if (count > JOYSTICK_COUNT)
count = JOYSTICK_COUNT;
- return count - 1;
+ if (count > 0)
+ return count - 1;
+ return 0;
}
That looks fishy ... how do you distinguish now between no joystick and one
joystick? Both will return 0 now here.
Thomas