forked from bartvdbraak/blender
BGE: fix use after free
This commit is contained in:
parent
fd629d2fb8
commit
edfe2d6691
@ -1080,6 +1080,16 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
|
|||||||
group->RemoveInstanceObject(newobj);
|
group->RemoveInstanceObject(newobj);
|
||||||
|
|
||||||
newobj->RemoveMeshes();
|
newobj->RemoveMeshes();
|
||||||
|
|
||||||
|
switch (newobj->GetGameObjectType()) {
|
||||||
|
case SCA_IObject::OBJ_CAMERA:
|
||||||
|
m_cameras.remove((KX_Camera *)newobj);
|
||||||
|
break;
|
||||||
|
case SCA_IObject::OBJ_TEXT:
|
||||||
|
m_fonts.remove((KX_FontObject *)newobj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT && m_lightlist->RemoveValue(newobj))
|
if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT && m_lightlist->RemoveValue(newobj))
|
||||||
ret = newobj->Release();
|
ret = newobj->Release();
|
||||||
@ -1095,7 +1105,10 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
|
|||||||
ret = newobj->Release();
|
ret = newobj->Release();
|
||||||
if (m_animatedlist->RemoveValue(newobj))
|
if (m_animatedlist->RemoveValue(newobj))
|
||||||
ret = newobj->Release();
|
ret = newobj->Release();
|
||||||
|
|
||||||
|
/* Warning 'newobj' maye be freed now, only compare, don't access */
|
||||||
|
|
||||||
|
|
||||||
if (newobj == m_active_camera)
|
if (newobj == m_active_camera)
|
||||||
{
|
{
|
||||||
//no AddRef done on m_active_camera so no Release
|
//no AddRef done on m_active_camera so no Release
|
||||||
@ -1103,12 +1116,6 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
|
|||||||
m_active_camera = NULL;
|
m_active_camera = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case this is a camera
|
|
||||||
m_cameras.remove((KX_Camera*)newobj);
|
|
||||||
|
|
||||||
// in case this is a font
|
|
||||||
m_fonts.remove((KX_FontObject*)newobj);
|
|
||||||
|
|
||||||
/* currently does nothing, keep in case we need to Unregister something */
|
/* currently does nothing, keep in case we need to Unregister something */
|
||||||
#if 0
|
#if 0
|
||||||
if (m_sceneConverter)
|
if (m_sceneConverter)
|
||||||
|
Loading…
Reference in New Issue
Block a user