Skip to content

Commit

Permalink
Try to avoid pointers to stack getting saved.
Browse files Browse the repository at this point in the history
Also, fix a harmless out of bounds »myUnusedPointer = &myVector[myVector.size()]«.

Introduced in d818ff5.

Hopefully fixes ticket:3200.
  • Loading branch information
Cyp committed Mar 12, 2012
1 parent a94bd66 commit da9d427
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/game.cpp
Expand Up @@ -5841,9 +5841,9 @@ static bool writeResearchFile(char *pFileName)
debug(LOG_ERROR, "Could not open %s", pFileName);
return false;
}
RESEARCH *psStats = &asResearch[0];
for (int i = 0; i < asResearch.size(); i++, psStats = &asResearch[i])
for (int i = 0; i < asResearch.size(); ++i)
{
RESEARCH *psStats = &asResearch[i];
bool valid = false;
QStringList possibles, researched, points;
for (int player = 0; player < game.maxPlayers; player++)
Expand Down
4 changes: 2 additions & 2 deletions src/research.cpp
Expand Up @@ -711,7 +711,7 @@ UWORD fillResearchList(UWORD *plist, UDWORD playerID, UWORD topic, UWORD limit)
/* process the results of a completed research topic */
void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE *psResearchFacility, bool bTrigger)
{
RESEARCH aResearch = asResearch[researchIndex], *pResearch = &aResearch;
RESEARCH * pResearch = &asResearch[researchIndex];
UDWORD type, inc;
STRUCTURE *psCurr;
DROID *psDroid;
Expand Down Expand Up @@ -1163,7 +1163,7 @@ void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE
}
if ((bMultiPlayer || player == selectedPlayer) && bTrigger)
{
psCBLastResearch = pResearch;
psCBLastResearch = pResearch; // Fun with pointers. Throw them into some random global variable, and get Nexus to absorb them.
CBResFacilityOwner = player;
psCBLastResStructure = psResearchFacility;
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_RESEARCHCOMPLETED);
Expand Down

0 comments on commit da9d427

Please sign in to comment.