]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix minor memory leaks.
authorVMware, Inc <>
Thu, 18 Nov 2010 22:54:52 +0000 (14:54 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 18 Nov 2010 22:54:52 +0000 (14:54 -0800)
. release a reference to a timeout source so it's properly freed.
. in the HGFS channel handling code, only initialize the channel's
connection once, since the channel is a static struct. This avoid
allocating a second transport-specific connection object (in the
init() callback) which would then be leaked.

Note that the HGFS fix is, for now, just a fix for the leak. There
are more issues with the static channel approach and the current code: for
example, the first app calling HgfsServerManager_Unregister() will shut
down the channel, instead of the last one, since the channel itself is not
ref counted.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c
open-vm-tools/services/plugins/timeSync/timeSync.c

index f7af6dbc7d6dfb9402d9c90932a4893c20c8933d..3d250c324eb83ab1ff521072b7351d3055036254 100644 (file)
@@ -146,7 +146,8 @@ HgfsChannelActivateChannel(HgfsChannelData *channel,                  // IN/OUT:
    Bool success = FALSE;
    struct HgfsGuestConn *connData = NULL;
 
-   if (channel->ops->init(serverCBTable, mgrData->rpc, mgrData->rpcCallback, &connData)) {
+   if (channel->connection == NULL &&
+       channel->ops->init(serverCBTable, mgrData->rpc, mgrData->rpcCallback, &connData)) {
       channel->state |= HGFS_CHANNEL_STATE_CBINIT;
       channel->connection = connData;
       success = TRUE;
index f2dffccce8c1035e9ddc41520cf097492d036dad..1f679eddc8022a8fe9d556f21f96204c22f1cda9 100644 (file)
@@ -684,6 +684,7 @@ TimeSyncStopLoop(ToolsAppCtx *ctx,
    TimeSync_DisableTimeSlew();
 
    g_source_destroy(data->timer);
+   g_source_unref(data->timer);
    data->timer = NULL;
 
    data->state = TIMESYNC_STOPPED;