Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Memory Leak Issue !!! #73

Open
Kiddinglife opened this issue Oct 26, 2015 · 1 comment
Open

Memory Leak Issue !!! #73

Kiddinglife opened this issue Oct 26, 2015 · 1 comment

Comments

@Kiddinglife
Copy link

I found memory leak issue everytime I assign a new queue to an old queue by using operator=. After debuging the source codes line by line in raknet, i found there is a bug in the impl of operator= function in line of 303 - 307 in DS_Queue.h file:
template
bool Queue<queue_type>::operator= ( const Queue& original_copy )
{
if ( ( &original_copy ) == this ) return false;
Clear(FILE_AND_LINE);
// Allocate memory for copy
if ( original_copy.Size() == 0 ) ///line 303
{
allocation_size = 0; /
} ///line 307
........
As you see, when original queue has size of 0, raknet just simply updates allocation_size to 0.

template
void Queue<queue_type>::Push( const queue_type& input, const char *file, unsigned int line )
{
if ( allocation_size == 0 )
{
array = RakNet::OP_NEW_ARRAY<queue_type>(16, file, line );
head = 0;
tail = 1;
array[ 0 ] = input;
allocation_size = 16;
return ;
}
......
So, When you then push a new element to this queue, you will get memory leak withput deleting the old array.

@larku
Copy link

larku commented Mar 4, 2016

Ouch, I'll fix that in the larku fork over the next few weeks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants