浏览代码

Tab Bar: Fixed buffer underflow in TabBarLayout, introduced by 4a57a982b (#3501, #3291)

+ Link to CI actions added in 3be352f
ocornut 5 年之前
父节点
当前提交
5f336ce8f8
共有 2 个文件被更改,包括 13 次插入6 次删除
  1. 4 0
      .github/workflows/build.yml
  2. 9 6
      imgui_widgets.cpp

+ 4 - 0
.github/workflows/build.yml

@@ -318,6 +318,7 @@ jobs:
     - name: Build example_sdl_opengl3
     - name: Build example_sdl_opengl3
       run: make -C examples/example_sdl_opengl3
       run: make -C examples/example_sdl_opengl3
 
 
+    # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord
     - uses: sarisia/actions-status-discord@v1
     - uses: sarisia/actions-status-discord@v1
       if: failure()
       if: failure()
       with:
       with:
@@ -381,6 +382,7 @@ jobs:
     - name: Build example_apple_opengl2
     - name: Build example_apple_opengl2
       run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
       run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
 
 
+    # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord
     - uses: sarisia/actions-status-discord@v1
     - uses: sarisia/actions-status-discord@v1
       if: failure()
       if: failure()
       with:
       with:
@@ -401,6 +403,7 @@ jobs:
         # Code signing is required, but we disable it because it is irrelevant for CI builds.
         # Code signing is required, but we disable it because it is irrelevant for CI builds.
         xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
         xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
 
 
+    # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord
     - uses: sarisia/actions-status-discord@v1
     - uses: sarisia/actions-status-discord@v1
       if: failure()
       if: failure()
       with:
       with:
@@ -431,6 +434,7 @@ jobs:
         popd
         popd
         make -C examples/example_emscripten
         make -C examples/example_emscripten
 
 
+    # Use https://github.com/marketplace/actions/actions-status-discord to send status to Discord
     - uses: sarisia/actions-status-discord@v1
     - uses: sarisia/actions-status-discord@v1
       if: failure()
       if: failure()
       with:
       with:

+ 9 - 6
imgui_widgets.cpp

@@ -6999,13 +6999,16 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
         tab->IndexDuringLayout = (ImS8)tab_dst_n;
         tab->IndexDuringLayout = (ImS8)tab_dst_n;
 
 
         // We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
         // We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
-        ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1];
         int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
         int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
-        int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
-        if (tab_dst_n > 0 && curr_tab_section_n == 0 && prev_tab_section_n != 0)
-            need_sort_by_section = true;
-        if (tab_dst_n > 0 && prev_tab_section_n == 2 && curr_tab_section_n != 2)
-            need_sort_by_section = true;
+        if (tab_dst_n > 0)
+        {
+            ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1];
+            int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
+            if (curr_tab_section_n == 0 && prev_tab_section_n != 0)
+                need_sort_by_section = true;
+            if (prev_tab_section_n == 2 && curr_tab_section_n != 2)
+                need_sort_by_section = true;
+        }
 
 
         sections[curr_tab_section_n].TabCount++;
         sections[curr_tab_section_n].TabCount++;
         tab_dst_n++;
         tab_dst_n++;