Skip to content

Commit

Permalink
Fixed recent GMPage crash (Issue #1136). Updated Coverity scan yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbnolok committed Oct 19, 2023
1 parent 2111840 commit d09b2f0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ jobs:
run: |
echo "GCC:" && gcc -v
echo && echo "CMake:" && cmake --version
echo && echo "Ninja:" && ninja --version
- name: Download Coverity Build Tool
env:
TOKEN: ${{ secrets.COVERITY_TOKEN }}
#echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
run: |
wget -nv https://scan.coverity.com/download/cxx/linux64 --post-data "token=${COVERITY_TOKEN}&project=SphereServer/Source-X" -O cov-analysis-linux64.tar.gz
wget -nv https://scan.coverity.com/download/cxx/linux64 --post-data "token=${TOKEN}&project=SphereServer/Source-X" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
Expand All @@ -69,13 +68,13 @@ jobs:
run: |
tar czvf build-data.tgz cov-int
curl \
--form project=SphereServer-X \
--form project=SphereServer/Source-X \
--form token=$TOKEN \
--form email=$EMAIL \
--form [email protected] \
--form version=trunk \
--form description="${{github.sha}}" \
https://scan.coverity.com/builds?project=SphereServer-X
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }}
TOKEN: ${{ secrets.COVERITY_TOKEN }}
EMAIL: ${{ secrets.COVERITY_EMAIL }}
17 changes: 8 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# Ignore folder and files
/.git/
/.vscode/
/CMakeFiles/
/spheresvr.dir/

/bin
/bin64
/Debug
/Release
/Nightly
/backup/
/.git/
/.vscode/
/x64/
/x86/
/obj/
/build/

/mul
/accounts/
/logs/
/save/
/web/
/CMakeFiles/
/spheresvr.dir/

*.vs
*.pid
Expand All @@ -30,13 +32,10 @@
*.o
*.obj
*.exe
*.vcxproj.*
*.vcx*
*.sln

# Ignore some files in the parent folder
/*.cmake
/*.vcx*
/*.sln
/*.sln
CMakeCache.txt

# Ignore git versioning file
Expand Down
2 changes: 1 addition & 1 deletion src/game/CServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3742,7 +3742,7 @@ bool CServerConfig::LoadResourceSection( CScript * pScript )

case RES_GMPAGE: // saved in world file. (Name is NOT DEFNAME)
{
CGMPage * pGMPage = new CGMPage( pScript->GetArgStr());
CGMPage * pGMPage = g_World.m_GMPages.emplace_back(std::make_shared<CGMPage>(pScript->GetArgStr())).get();
return pGMPage->r_Load( *pScript );
}
case RES_WC:
Expand Down
2 changes: 1 addition & 1 deletion src/game/CWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void CWorldThread::GarbageCollection_NewObjs()
// Clean up GM pages not linked to an valid char/account
for (auto it = g_World.m_GMPages.begin(); it != g_World.m_GMPages.end();)
{
std::unique_ptr<CGMPage>& pGMPage = *it;
std::shared_ptr<CGMPage>& pGMPage = *it;
if (!pGMPage->m_uidChar.CharFind())
{
DEBUG_ERR(("GC: Deleted GM Page linked to invalid char (UID=0%x)\n", (dword)(pGMPage->m_uidChar)));
Expand Down
6 changes: 3 additions & 3 deletions src/game/CWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ extern class CWorld : public CScriptObj, public CWorldThread
CUID m_uidObj; // for script access - auxiliary obj
CUID m_uidNew; // for script access - auxiliary obj

CSUniquePtrVector<CGMPage> m_GMPages; // Owns current outstanding GM pages. (CGMPage)
CSUniquePtrVector<CItemStone> m_Stones; // Owns guild/town stones. (not saved array)
CSSharedPtrVector<CGMPage> m_GMPages; // Owns current outstanding GM pages. (CGMPage)
CSSharedPtrVector<CItemStone> m_Stones; // Owns guild/town stones. (not saved array)
CSUniquePtrVector<CPartyDef> m_Parties; // Owns all active parties.
CSUniquePtrVector<CItemMulti> m_Multis; //
CSUniquePtrVector<CItemMulti> m_Multis; // World multis?
CSWeakPtrVector<CResourceDef> m_TileTypes; // Links to CItemTypeDef items owned by g_Cfg.m_ResHash

public:
Expand Down
2 changes: 1 addition & 1 deletion src/game/clients/CClientEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ void CClient::Event_PromptResp_GMPage(lpctstr pszReason)
}
else
{
pGMPage = new CGMPage(m_pAccount->GetName());
pGMPage = g_World.m_GMPages.emplace_back(std::make_shared<CGMPage>(m_pAccount->GetName())).get();
SysMessageDefault(DEFMSG_GMPAGE_SENT);
}
pGMPage->m_uidChar = m_pChar->GetUID();
Expand Down
5 changes: 1 addition & 4 deletions src/game/clients/CGMPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ CGMPage::CGMPage( lpctstr pszAccount )
m_sAccount = pszAccount;
m_sReason = nullptr;
m_time = CWorldGameTime::GetCurrentTime().GetTimeRaw();

g_World.m_GMPages.emplace_back(this); // put it at the end of the list
}

CGMPage::~CGMPage()
Expand Down Expand Up @@ -120,7 +118,6 @@ bool CGMPage::r_WriteVal(lpctstr pszKey, CSString &sVal, CTextConsole *pSrc, boo
return false;
}


bool CGMPage::r_LoadVal(CScript& s)
{
ADDTOCALLSTACK("CGMPage::r_LoadVal");
Expand All @@ -131,7 +128,7 @@ bool CGMPage::r_LoadVal(CScript& s)
m_uidChar.SetObjUID(s.GetArgDWVal());
break;
case GC_DELETE:
delete this;
g_World.m_GMPages.erase_element(this);
break;
case GC_HANDLED:
{
Expand Down

0 comments on commit d09b2f0

Please sign in to comment.