Skip to content

[rcore][RGFW] Fix mg_gamepads_free() iterating freed list nodes#5903

Open
robknopf wants to merge 1 commit into
raysan5:masterfrom
robknopf:fix/rgfw-minigamepad-free-loop
Open

[rcore][RGFW] Fix mg_gamepads_free() iterating freed list nodes#5903
robknopf wants to merge 1 commit into
raysan5:masterfrom
robknopf:fix/rgfw-minigamepad-free-loop

Conversation

@robknopf
Copy link
Copy Markdown

@robknopf robknopf commented Jun 3, 2026

The for loop in mg_gamepads_free() captured cur->prev before calling mg_gamepad_release(). If the release mutated or freed the node, the next iteration would follow a stale pointer. Changed to a while loop that reads gamepads->list.cur fresh each iteration.

@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Jun 3, 2026

@robknopf I'm afraid this reeview should be implemented in RGFW repo or it will be override when updating the library

@raysan5 raysan5 added the external This issue depends on external lib label Jun 3, 2026
@raysan5 raysan5 changed the title [RGFW] Fix mg_gamepads_free() iterating freed list nodes [rcor][RGFW] Fix mg_gamepads_free() iterating freed list nodes Jun 3, 2026
@raysan5 raysan5 changed the title [rcor][RGFW] Fix mg_gamepads_free() iterating freed list nodes [rcore][RGFW] Fix mg_gamepads_free() iterating freed list nodes Jun 3, 2026
@raysan5 raysan5 changed the title [rcore][RGFW] Fix mg_gamepads_free() iterating freed list nodes [rcore][RGFW] Fix mg_gamepads_free() iterating freed list nodes Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external This issue depends on external lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants