From 606aa392c7c15206a102bb60cb74e7490b7da389 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Tue, 17 Dec 2013 23:57:45 -0800 Subject: [PATCH] - added coverity linux script - a few updates to fix coverity reported issues --- source/glest_game/menu/menu_state_custom_game.cpp | 10 ++++------ .../sources/compression/compression_utils.cpp | 5 +++++ source/tools/glexemel/g2xml.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 832a7cce6..7cf27bfa5 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1816,16 +1816,14 @@ void MenuStateCustomGame::PlayNow(bool saveGame) { mainMessageBoxState=1; Lang &lang= Lang::getInstance(); - char szMsg[1024]=""; - strcpy(szMsg,lang.getString("NetworkSlotNoHumanErrorUI","",true).c_str()); - showMessageBox(szMsg, "", false); + string sMsg = lang.getString("NetworkSlotNoHumanErrorUI","",true); + showMessageBox(sMsg, "", false); const vector languageList = serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages(); for(unsigned int j = 0; j < languageList.size(); ++j) { - char szMsg[1024]=""; - strcpy(szMsg,lang.getString("NetworkSlotNoHumanError","",true).c_str()); + sMsg = lang.getString("NetworkSlotNoHumanError","",true); - serverInterface->sendTextMessage(szMsg,-1, true,languageList[j]); + serverInterface->sendTextMessage(sMsg,-1, true,languageList[j]); } safeMutex.ReleaseLock(); diff --git a/source/shared_lib/sources/compression/compression_utils.cpp b/source/shared_lib/sources/compression/compression_utils.cpp index c6966b35f..cb935957f 100644 --- a/source/shared_lib/sources/compression/compression_utils.cpp +++ b/source/shared_lib/sources/compression/compression_utils.cpp @@ -191,6 +191,8 @@ int zipfile_tool(int argc, const char *argv[]) { } else if (status != Z_OK) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("deflate() failed with status %i!\n", status); + if(pInfile) fclose(pInfile); + if(pOutfile) fclose(pOutfile); return EXIT_FAILURE; } } @@ -207,6 +209,7 @@ int zipfile_tool(int argc, const char *argv[]) { if (inflateInit(&stream)) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflateInit() failed!\n"); if(pInfile) fclose(pInfile); + if(pOutfile) fclose(pOutfile); return EXIT_FAILURE; } @@ -218,6 +221,7 @@ int zipfile_tool(int argc, const char *argv[]) { if (fread(s_inbuf, 1, n, pInfile) != n) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Failed reading from input file!\n"); + if(pInfile) fclose(pInfile); if(pOutfile) fclose(pOutfile); return EXIT_FAILURE; } @@ -246,6 +250,7 @@ int zipfile_tool(int argc, const char *argv[]) { } else if (status != Z_OK) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflate() failed with status %i!\n", status); + if(pInfile) fclose(pInfile); if(pOutfile) fclose(pOutfile); return EXIT_FAILURE; } diff --git a/source/tools/glexemel/g2xml.c b/source/tools/glexemel/g2xml.c index 4bb64a254..f20e5c106 100644 --- a/source/tools/glexemel/g2xml.c +++ b/source/tools/glexemel/g2xml.c @@ -185,7 +185,7 @@ int g3d2xml(FILE *infile, FILE *outfile) printf("Could not read mesh header!\n"); return FALSE; } - + meshHeader.name[NAMESIZE-1] = 0; /* write out XML mesh header */ fprintf(outfile, "\t