SimCutie
Warlord
- Joined
- Dec 10, 2005
- Messages
- 197
CyArtFileMgr().getXXXArtInfo("art_tag") will crash (CTD) if the art_tag is wrong tag. It should return NULL, not crash.
For example, CyArtFileMgr().getInterfaceArtfo("wrong_name") will hang in infinite recursive call, and crash.
Lets see the CvGameCoreDLL SDK source code: It is macro defintion..
The line marked with bold (line 72) is obviously wrong C++ statement. Data type of szArtDefineTag is const char *. You can not use == operator to compare with constant string "ERROR".
This make it evalued to always false and fall into else part and infinite recursive call to itself and crash.
The right line sholde be like this:
For example, CyArtFileMgr().getInterfaceArtfo("wrong_name") will hang in infinite recursive call, and crash.
Lets see the CvGameCoreDLL SDK source code: It is macro defintion..
Code:
CvArtFileMgr.cpp: line 63 - line 83
CvArtInfo##name##* CvArtFileMgr::get##name##ArtInfo( [B]const char *szArtDefineTag [/B]) const \
{ \
FAssertMsg(szArtDefineTag, "NULL string on art info lookup?"); \
ArtInfo##name##MapType::const_iterator it = m_map##name##ArtInfos->find( szArtDefineTag );\
if ( it == m_map##name##ArtInfos->end() ) \
{\
char szErrorMsg[256]; \
sprintf(szErrorMsg, "get##name##ArtInfo: %s was not found", szArtDefineTag); \
FAssertMsg(false, szErrorMsg ); \
if ( [B]szArtDefineTag == "ERROR" [/B]) \
{ \
return NULL; \
} \
else \
{ \
return get##name##ArtInfo( "ERROR" ); \
} \
} \
return it->second; \
} \
CvArtInfo##name##& CvArtFileMgr::get##name##ArtInfo(int i) { return m_pa##name##ArtInfo[i]; }
This make it evalued to always false and fall into else part and infinite recursive call to itself and crash.
The right line sholde be like this:
Code:
line 72:
BEFORE:
if ( szArtDefineTag == "ERROR" ) \
AFTER:
if ( strcmp(szArtDefineTag, "ERROR") == 0 ) \