Skip to content

Commit ca9b7c8

Browse files
committed
video: Explicitly disallow setting the parent of a window to itself
Doing so causes a cycle in the window hierarchy tree graph, which leads to infinite recursion when destroying the windows.
1 parent c046249 commit ca9b7c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/video/SDL_video.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,6 +3672,10 @@ bool SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent)
36723672
CHECK_WINDOW_NOT_POPUP(parent, false);
36733673
}
36743674

3675+
if (window == parent) {
3676+
return SDL_SetError("Cannot set the parent of a window to itself.");
3677+
}
3678+
36753679
if (!_this->SetWindowParent) {
36763680
return SDL_Unsupported();
36773681
}

0 commit comments

Comments
 (0)