Skip to content

Commit

Permalink
Fixed Coverity reported issue.
Browse files Browse the repository at this point in the history
CID 11388: Resource leak in object (CTOR_DTOR_LEAK)
Allocating memory by calling "new char[numBytes]".
Assigning: "this->_startPtr" = "new char[numBytes]".
The constructor allocates field "_startPtr" of "struct DataConverter" but there is no destructor.
Assigning: "this->_currentPtr" = "new char[numBytes]".
The constructor allocates field "_currentPtr" of "struct DataConverter" but there is no destructor.
  • Loading branch information
robertosfield committed May 6, 2011
1 parent e6217e3 commit 8df1106
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 16 additions & 6 deletions applications/present3D/Cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,11 @@ class DataConverter
_numBytes = numBytes;
}

char* _startPtr;
char* _endPtr;
unsigned int _numBytes;
bool _swapBytes;
~DataConverter()
{
delete [] _startPtr;
}

char* _currentPtr;

void reset()
{
_currentPtr = _startPtr;
Expand Down Expand Up @@ -327,6 +325,18 @@ class DataConverter

void write(CameraPacket& cameraPacket);
void read(CameraPacket& cameraPacket);

char* startPtr() { return _startPtr; }
unsigned int numBytes() { return _numBytes; }

protected:

char* _startPtr;
char* _endPtr;
unsigned int _numBytes;
bool _swapBytes;

char* _currentPtr;
};


Expand Down
6 changes: 3 additions & 3 deletions applications/present3D/present3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,15 +918,15 @@ int main( int argc, char **argv )
scratchPad.reset();
scratchPad.read(cp);

bc.setBuffer(scratchPad._startPtr, scratchPad._numBytes);
bc.setBuffer(scratchPad.startPtr(), scratchPad.numBytes());

std::cout << "bc.sync()"<<scratchPad._numBytes<<std::endl;
std::cout << "bc.sync()"<<scratchPad.numBytes()<<std::endl;

bc.sync();
}
else if (P3DApplicationType==SLAVE)
{
rc.setBuffer(scratchPad._startPtr, scratchPad._numBytes);
rc.setBuffer(scratchPad.startPtr(), scratchPad.numBytes());

rc.sync();

Expand Down

0 comments on commit 8df1106

Please sign in to comment.