intel/aub_viewer: fix access to freed memory
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 17 Jul 2019 11:42:49 +0000 (14:42 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 3 Apr 2020 12:46:24 +0000 (15:46 +0300)
Windows closed while we're displaying them might lead to invalid
memory accessed, so use the safe iterators on the list of windows.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4430>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4430>

src/intel/tools/aubinator_viewer.cpp

index 140cde5bbbce56023fd0a89d1571170fdccaac44..46ab9238ce14355a8f30267b10536b461c2fa7ad 100644 (file)
@@ -1085,7 +1085,7 @@ display_windows(void)
          window->destroy(window);
    }
 
-   list_for_each_entry(struct window, window, &context.windows, link) {
+   list_for_each_entry_safe(struct window, window, &context.windows, link) {
       ImGui::SetNextWindowPos(window->position, ImGuiCond_FirstUseEver);
       ImGui::SetNextWindowSize(window->size, ImGuiCond_FirstUseEver);
       if (ImGui::Begin(window->name, &window->opened)) {