CCMutableArray::count() may crash if m_array is empty. Detect empty() before iteration

This commit is contained in:
Walzer 2011-04-19 11:23:02 +08:00
parent 32342d376a
commit 735b6ce97b
1 changed files with 10 additions and 6 deletions

View File

@ -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;