Skip to content

Commit

Permalink
Prevent client crashing if an NDT_AIRLIKE node is dropped
Browse files Browse the repository at this point in the history
The player dropping the node can either be themselves or another player (i.e. without this fix you can crash other people's clients)
Thanks CWz for reporting the issue
  • Loading branch information
Zeno- committed Jan 5, 2015
1 parent 2d849b0 commit beb6b3e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/wieldmesh.cpp
Expand Up @@ -411,20 +411,20 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
m_meshnode->setVisible(false);
m_meshnode->setMesh(dummymesh);
dummymesh->drop(); // m_meshnode grabbed it
}

if (m_lighting) {
m_meshnode->setMesh(mesh);
} else {
/*
Lighting is disabled, this means the caller can (and probably will)
call setColor later. We therefore need to clone the mesh so that
setColor will only modify this scene node's mesh, not others'.
*/
scene::IMeshManipulator *meshmanip = SceneManager->getMeshManipulator();
scene::IMesh *new_mesh = meshmanip->createMeshCopy(mesh);
m_meshnode->setMesh(new_mesh);
new_mesh->drop(); // m_meshnode grabbed it
if (m_lighting) {
m_meshnode->setMesh(mesh);
} else {
/*
Lighting is disabled, this means the caller can (and probably will)
call setColor later. We therefore need to clone the mesh so that
setColor will only modify this scene node's mesh, not others'.
*/
scene::IMeshManipulator *meshmanip = SceneManager->getMeshManipulator();
scene::IMesh *new_mesh = meshmanip->createMeshCopy(mesh);
m_meshnode->setMesh(new_mesh);
new_mesh->drop(); // m_meshnode grabbed it
}
}

m_meshnode->setMaterialFlag(video::EMF_LIGHTING, m_lighting);
Expand Down

0 comments on commit beb6b3e

Please sign in to comment.