Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Possibly memory leak SSGM
Possibly memory leak SSGM [message #487458] Thu, 01 May 2014 10:47 Go to previous message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma:
Recruit
So I was going trough some code and I found my way to the file gmlog.cpp

The logger keeps track of the current socket connections it has in a SimpleDynVecClass list. However this class does not use the delete operator on its contents when you call ::Delete.

So I found these 2 leaks:

- in void SSGMGameLog::Think()

where you gracefully close the sockets upon error or something else you call Connections.Delete(Connections[i]); this does not however delete the resources to Connections[i].

- in void SSGMGameLog::Shutdown()

you loop trough all connections and close the sockets, however no memory is released trough this process.


All objects inside this list are created with the new operator, however no subsequent delete operators are called.

I might be completly wrong at this, but anyway it's worth reporting i suppose...

EDIT:

Further explenation:

bool Delete(int index,bool allow_shrink = true)
	{
		if (index < ActiveCount-1)
		{
			memmove(&(Vector[index]),&(Vector[index+1]),(ActiveCount - index - 1) * sizeof(T));
		}
		ActiveCount--;
		if (allow_shrink)
		{
			Shrink();
		}
		return true;
	}
	bool Delete(T const & object,bool allow_shrink = true)
	{
		int id = Find_Index(object);
		if (id != -1)
		{
			return Delete(id,allow_shrink);
		}
		return false;
	}


these are the 2 overloaded functions inside SimpleDynVecClass. As you can see it only uses memmove which doesn't guarantee that the resources are overwritten. The code in gmlog.cpp calls the bottom Delete first, which then calls the top one if there's an index found.

[Updated on: Thu, 01 May 2014 12:52]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Commands->Select_Weapon doesn't work clientside.
Next Topic: Quick brenbot question.
Goto Forum:
  


Current Time: Sun Dec 22 05:01:50 MST 2024

Total time taken to generate the page: 0.00650 seconds