Fix clang-analyzer-core.CallAndMessage

/media/ddnet/src/game/editor/auto_map.cpp:94:17: warning: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage]
                                int RunID = pCurrentConf->m_aRuns.add(NewRun);
                                            ^
This commit is contained in:
def 2020-10-12 18:50:23 +02:00
parent 0867424749
commit 6443e708b5
4 changed files with 12 additions and 6 deletions

View file

@ -551,6 +551,11 @@ int CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int Sto
pImg->m_Format = CImageInfo::FORMAT_RGB;
else if(Png.color_type == PNG_TRUECOLOR_ALPHA) // ignore_convention
pImg->m_Format = CImageInfo::FORMAT_RGBA;
else
{
free(pBuffer);
return 0;
}
pImg->m_pData = pBuffer;
return 1;
}

View file

@ -58,7 +58,8 @@ void CCountryFlags::LoadCountryflagsIndexfile()
// load the graphic file
char aBuf[128];
CImageInfo Info;
if(g_Config.m_ClLoadCountryFlags)
bool LoadCountryFlags = g_Config.m_ClLoadCountryFlags;
if(LoadCountryFlags)
{
str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin);
if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL))
@ -74,7 +75,7 @@ void CCountryFlags::LoadCountryflagsIndexfile()
CCountryFlag CountryFlag;
CountryFlag.m_CountryCode = CountryCode;
str_copy(CountryFlag.m_aCountryCodeString, aOrigin, sizeof(CountryFlag.m_aCountryCodeString));
if(g_Config.m_ClLoadCountryFlags)
if(LoadCountryFlags)
{
CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
free(Info.m_pData);

View file

@ -48,10 +48,10 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
float Strength = GetTuning(m_TuneZone)->m_ShotgunStrength;
if(!g_Config.m_SvOldLaser)
Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - pHit->Core()->m_Pos) * Strength;
else
if(g_Config.m_SvOldLaser && pOwnerChar)
Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - pHit->Core()->m_Pos) * Strength;
else
Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - pHit->Core()->m_Pos) * Strength;
pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp);
}
else if(m_Type == WEAPON_LASER)

View file

@ -86,7 +86,7 @@ void CAutoMapper::Load(const char *pTileName)
int RunID = pCurrentConf->m_aRuns.add(NewRun);
pCurrentRun = &pCurrentConf->m_aRuns[RunID];
}
else if(str_startswith(pLine, "NewRun"))
else if(str_startswith(pLine, "NewRun") && pCurrentConf)
{
// add new run
CRun NewRun;