Prevent client crashing if an NDT_AIRLIKE node is dropped
authorCraig Robbins <kde.psych@gmail.com>
Mon, 5 Jan 2015 12:39:08 +0000 (22:39 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Mon, 5 Jan 2015 12:55:02 +0000 (22:55 +1000)
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

src/wieldmesh.cpp

index bde0b72afe9f0e69ac92850e59f31dbc79dd2633..4ddae36d485deda8569923edf40c8b1a054a68cd 100644 (file)
@@ -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);