Fixed Coverity reported issues.

CID 11389: Resource leak in object (CTOR_DTOR_LEAK)
Allocating memory by calling "new bsp::VBSPData".
Assigning: "this->bsp_data" = "new bsp::VBSPData".
The constructor allocates field "bsp_data" of "struct bsp::VBSPReader" but the destructor and whatever functions it calls do not free it.
This commit is contained in:
Robert Osfield
2011-05-06 09:20:06 +00:00
parent 67c12b14b0
commit 31aa1cdfee
3 changed files with 5 additions and 4 deletions

View File

@@ -162,7 +162,7 @@ struct DisplacedVertex
};
class VBSPData
class VBSPData : public osg::Referenced
{
protected:
@@ -211,10 +211,11 @@ protected:
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
StateSetList state_set_list;
virtual ~VBSPData();
public:
VBSPData();
virtual ~VBSPData();
void addEntity(std::string & newEntity);
const int getNumEntities() const;

View File

@@ -1055,7 +1055,7 @@ void VBSPReader::createScene()
{
// Get the entity
entityText = bsp_data->getEntity(i);
currentEntity = new VBSPEntity(entityText, bsp_data);
currentEntity = new VBSPEntity(entityText, bsp_data.get());
// See if the entity is visible
if (currentEntity->isVisible())

View File

@@ -233,7 +233,7 @@ protected:
std::string map_name;
VBSPData * bsp_data;
osg::ref_ptr<VBSPData> bsp_data;
osg::ref_ptr<osg::Node> root_node;