mirror of https://github.com/axmolengine/axmol.git
CCMutableArray::count() may crash if m_array is empty. Detect empty() before iteration
This commit is contained in:
parent
32342d376a
commit
735b6ce97b
|
@ -55,15 +55,19 @@ public:
|
|||
unsigned int count(void)
|
||||
{
|
||||
unsigned int uCount = 0;
|
||||
CCMutableArrayIterator it;
|
||||
for (it = m_array.begin(); it != m_array.end(); ++it)
|
||||
|
||||
if (!m_array.empty())
|
||||
{
|
||||
if (*it == NULL)
|
||||
CCMutableArrayIterator it;
|
||||
for (it = m_array.begin(); it != m_array.end(); ++it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (*it == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++uCount;
|
||||
++uCount;
|
||||
}
|
||||
}
|
||||
|
||||
return uCount;
|
||||
|
|
Loading…
Reference in New Issue