fixed #1862: CCScrollView::setContainer may cause dangling pointer when NULL is passed into.

This commit is contained in:
James Chen 2013-04-15 09:52:46 +08:00
parent fdd6529bd2
commit 6c15c75c78
1 changed files with 5 additions and 3 deletions

View File

@ -305,10 +305,12 @@ CCNode * CCScrollView::getContainer()
void CCScrollView::setContainer(CCNode * pContainer)
{
// Make sure that 'm_pContainer' has a non-NULL value since there are
// lots of logic that use 'm_pContainer'.
if (NULL == pContainer)
return;
this->removeAllChildrenWithCleanup(true);
if (!pContainer) return;
this->m_pContainer = pContainer;
this->m_pContainer->ignoreAnchorPointForPosition(false);