Skip to content

Commit

Permalink
Do not use std::string in a memory structure that is memset().
Browse files Browse the repository at this point in the history
Patch by tnmurphy, closes ticket:3620
  • Loading branch information
perim committed Jul 30, 2012
1 parent df32833 commit fdb1c0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/netplay/netplay.cpp
Expand Up @@ -1989,7 +1989,7 @@ UBYTE NETrecvFile(NETQUEUE queue)

}
NetPlay.pMapFileHandle = PHYSFS_openWrite(fileName); // create a new file.
NetPlay.mapFileName = fileName;
sstrcpy(NetPlay.mapFileName, fileName);
}

debug(LOG_NET, "New file position is %d", currPos);
Expand Down Expand Up @@ -2022,10 +2022,10 @@ UBYTE NETrecvFile(NETQUEUE queue)
debug(LOG_ERROR, "Could not close file handle after trying to save map: %s", PHYSFS_getLastError());
}
NetPlay.pMapFileHandle = NULL;
PHYSFS_File *file = PHYSFS_openRead(NetPlay.mapFileName.c_str());
PHYSFS_File *file = PHYSFS_openRead(NetPlay.mapFileName);
int actualFileSize = PHYSFS_fileLength(file);
PHYSFS_close(file);
NetPlay.mapFileName.clear();
NetPlay.mapFileName[0] = '\0';
ASSERT(actualFileSize == fileSize, "Downloaded map too small! Got %d, expected %d!", actualFileSize, fileSize);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/netplay/netplay.h
Expand Up @@ -273,7 +273,7 @@ struct NETPLAY
bool isUPNP; // if we want the UPnP detection routines to run
bool isHostAlive; /// if the host is still alive
PHYSFS_file * pMapFileHandle; ///< Only non-NULL during map download.
std::string mapFileName; ///< Only valid during map download.
char mapFileName[255]; ///< Only valid during map download.
char gamePassword[password_string_size]; //
bool GamePassworded; // if we have a password or not.
bool ShowedMOTD; // only want to show this once
Expand Down

0 comments on commit fdb1c0b

Please sign in to comment.