List Info

Thread: Re: Add splay (Atlas310) as Helix engine(client core) for Helix dbus-server




Re: Add splay (Atlas310) as Helix engine(client core) for Helix dbus-server
country flaguser name
United States
2007-10-25 23:20:41
Greg Wright wrote:
> This is a memory leak. EACH time you call
g_build_filename you
> NEED to call g_free(clntcore_path).

> It looks like it was a memory leak before as well.
>
> + g_debug("helix-dbus-server running against
%s", clntcore_path);
> + g_free(clntcore_path);
>
> make sure you are not double-free'ing something here. 

Zhao, Halley wrote:
>   Hi Greg:
>   You can refer the whole code below (the patch file
doesn't express it well); I think the clntcore_path is freed
each time.
>   When the client core path is found, there is a
"break" from the loop, then the following code can
free it after using.
>   

My opinion is that it is a good practice to set the variable
to NULL
after freeing the memory. It is too easy for someone to
change the flow
of the code a little and you get a double free. If you were
to set it to
NULL, that would not happen.

-- 
Daniel Yek.





_______________________________________________
Player-dev mailing list
Player-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/play
er-dev

RE: Add splay (Atlas310) as Helix engine(client core) for Helix dbus-server
user name
2007-10-26 20:19:30
  Thanks, Daniel:
  I added "clntcore_path = NULL" when I commit.
  
  
  >-----Original Message-----
  >From: Daniel Yek [mailto:dyekreal.com]
  >Sent: 2007定10埖26晩 12:21
  >To: Zhao, Halley
  >Cc: player-devhelixcommunity.org
  >Subject: Re: Add splay (Atlas310) as Helix
engine(client core) for Helix
  >dbus-server
  >
  >
  >Greg Wright wrote:
  >> This is a memory leak. EACH time you call
g_build_filename you
  >> NEED to call g_free(clntcore_path).
  >
  >> It looks like it was a memory leak before as
well.
  >>
  >> + g_debug("helix-dbus-server running
against %s", clntcore_path);
  >> + g_free(clntcore_path);
  >>
  >> make sure you are not double-free'ing something
here.
  >
  >Zhao, Halley wrote:
  >>   Hi Greg:
  >>   You can refer the whole code below (the
patch file doesn't express
  >it well); I think the clntcore_path is freed each
time.
  >>   When the client core path is found, there
is a "break" from the loop,
  >then the following code can free it after using.
  >>
  >
  >My opinion is that it is a good practice to set the
variable to NULL
  >after freeing the memory. It is too easy for someone
to change the flow
  >of the code a little and you get a double free. If
you were to set it to
  >NULL, that would not happen.
  >
  >--
  >Daniel Yek.
  >
  

_______________________________________________
Player-dev mailing list
Player-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/play
er-dev

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )