Przeglądaj źródła

Fixed undefined behavior on accessing array with -1 index

Ivan Savenko 1 rok temu
rodzic
commit
d5f8db2222
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      client/windows/CSpellWindow.cpp

+ 8 - 1
client/windows/CSpellWindow.cpp

@@ -648,7 +648,14 @@ void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
 
 
 		{
 		{
 			OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
 			OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
-			schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool.getNum() : owner->selectedTab], schoolLevel);
+			schoolBorder.reset();
+			if (owner->selectedTab >= 4)
+			{
+				if (whichSchool.getNum() != SpellSchool())
+					schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders.at(whichSchool.getNum()), schoolLevel);
+			}
+			else
+				schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders.at(owner->selectedTab), schoolLevel);
 		}
 		}
 
 
 		ColorRGBA firstLineColor, secondLineColor;
 		ColorRGBA firstLineColor, secondLineColor;