Prevent bad access potential for removals by checking bounds (#4617)
* Prevent bad access potential for removals by checking bounds Fix #4616 Switch to removeOne instead of bound checking removeAt * Revert server cardzone check
This commit is contained in:
parent
b02adccf87
commit
3e90f109a2
7 changed files with 10 additions and 12 deletions
|
@ -43,9 +43,8 @@ public:
|
||||||
}
|
}
|
||||||
void removeArrowFrom(ArrowItem *arrow)
|
void removeArrowFrom(ArrowItem *arrow)
|
||||||
{
|
{
|
||||||
arrowsFrom.removeAt(arrowsFrom.indexOf(arrow));
|
arrowsFrom.removeOne(arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ArrowItem *> &getArrowsTo() const
|
const QList<ArrowItem *> &getArrowsTo() const
|
||||||
{
|
{
|
||||||
return arrowsTo;
|
return arrowsTo;
|
||||||
|
@ -56,8 +55,7 @@ public:
|
||||||
}
|
}
|
||||||
void removeArrowTo(ArrowItem *arrow)
|
void removeArrowTo(ArrowItem *arrow)
|
||||||
{
|
{
|
||||||
arrowsTo.removeAt(arrowsTo.indexOf(arrow));
|
arrowsTo.removeOne(arrow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
}
|
}
|
||||||
void removeAttachedCard(CardItem *card)
|
void removeAttachedCard(CardItem *card)
|
||||||
{
|
{
|
||||||
attachedCards.removeAt(attachedCards.indexOf(card));
|
attachedCards.removeOne(card);
|
||||||
}
|
}
|
||||||
const QList<CardItem *> &getAttachedCards() const
|
const QList<CardItem *> &getAttachedCards() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -187,7 +187,7 @@ CardItem *CardZone::takeCard(int position, int cardId, bool /*canResize*/)
|
||||||
|
|
||||||
void CardZone::removeCard(CardItem *card)
|
void CardZone::removeCard(CardItem *card)
|
||||||
{
|
{
|
||||||
cards.removeAt(cards.indexOf(card));
|
cards.removeOne(card);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
emit cardCountChanged();
|
emit cardCountChanged();
|
||||||
player->deleteCard(card);
|
player->deleteCard(card);
|
||||||
|
|
|
@ -216,7 +216,7 @@ void DeckViewCardContainer::addCard(DeckViewCard *card)
|
||||||
|
|
||||||
void DeckViewCardContainer::removeCard(DeckViewCard *card)
|
void DeckViewCardContainer::removeCard(DeckViewCard *card)
|
||||||
{
|
{
|
||||||
cards.removeAt(cards.indexOf(card));
|
cards.removeOne(card);
|
||||||
cardsByType.remove(card->getInfo() ? card->getInfo()->getMainCardType() : "", card);
|
cardsByType.remove(card->getInfo() ? card->getInfo()->getMainCardType() : "", card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ void GameScene::removePlayer(Player *player)
|
||||||
zone->close();
|
zone->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
players.removeAt(players.indexOf(player));
|
players.removeOne(player);
|
||||||
removeItem(player);
|
removeItem(player);
|
||||||
rearrange();
|
rearrange();
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ void GameScene::addRevealedZoneView(Player *player,
|
||||||
|
|
||||||
void GameScene::removeZoneView(ZoneViewWidget *item)
|
void GameScene::removeZoneView(ZoneViewWidget *item)
|
||||||
{
|
{
|
||||||
zoneViews.removeAt(zoneViews.indexOf(item));
|
zoneViews.removeOne(item);
|
||||||
removeItem(item);
|
removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,7 @@ void TabSupervisor::replayLeft(TabGame *tab)
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
|
|
||||||
replayTabs.removeAt(replayTabs.indexOf(tab));
|
replayTabs.removeOne(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
||||||
|
@ -508,7 +508,7 @@ void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
|
|
||||||
deckEditorTabs.removeAt(deckEditorTabs.indexOf(tab));
|
deckEditorTabs.removeOne(tab);
|
||||||
removeTab(indexOf(tab));
|
removeTab(indexOf(tab));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ public:
|
||||||
}
|
}
|
||||||
void removeAttachedCard(Server_Card *card)
|
void removeAttachedCard(Server_Card *card)
|
||||||
{
|
{
|
||||||
attachedCards.removeAt(attachedCards.indexOf(card));
|
attachedCards.removeOne(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetState();
|
void resetState();
|
||||||
|
|
Loading…
Reference in a new issue