Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2017-12-21 19:16:14 -0500
committerEugene Tarassov2017-12-21 19:16:14 -0500
commit60db05b003178e380585452aa026bf77d5c737e7 (patch)
tree1df491a7001a55cb01d0bd24a26d1f440153bdf3
parent1acbfd7a9acbe2c205a1ec7306b956db0ecd3db4 (diff)
downloadorg.eclipse.tcf.agent-60db05b003178e380585452aa026bf77d5c737e7.tar.gz
org.eclipse.tcf.agent-60db05b003178e380585452aa026bf77d5c737e7.tar.xz
org.eclipse.tcf.agent-60db05b003178e380585452aa026bf77d5c737e7.zip
TCF Agent: fixed memory leak (second try)
-rw-r--r--agent/tcf/framework/cache.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/agent/tcf/framework/cache.c b/agent/tcf/framework/cache.c
index 2d22ec22..62fb03dc 100644
--- a/agent/tcf/framework/cache.c
+++ b/agent/tcf/framework/cache.c
@@ -91,11 +91,13 @@ static void run_cache_client(int retry) {
Trap trap;
unsigned i;
unsigned id = current_client.id;
+ void * args_copy = NULL;
assert(id != 0);
current_cache = NULL;
cache_miss_cnt = 0;
def_channel = NULL;
+ if (current_client.args_copy) args_copy = current_client.args;
for (i = 0; i < listeners_cnt; i++) listeners[i](retry ? CTLE_RETRY : CTLE_START);
if (set_trap(&trap)) {
current_client.client(current_client.args);
@@ -112,7 +114,6 @@ static void run_cache_client(int retry) {
if (get_error_code(trap.error) != ERR_CACHE_MISS || cache_miss_cnt == 0 || current_cache == NULL) {
trace(LOG_ALWAYS, "Unhandled exception in data cache client: %s", errno_to_str(trap.error));
for (i = 0; i < listeners_cnt; i++) listeners[i](CTLE_COMMIT);
- if (current_client.args_copy) loc_free(current_client.args);
}
else {
AbstractCache * cache = current_cache;
@@ -130,12 +131,14 @@ static void run_cache_client(int retry) {
if (current_client.channel != NULL) channel_lock_with_msg(current_client.channel, channel_lock_msg);
cache->wait_list_buf[cache->wait_list_cnt++] = current_client;
for (i = 0; i < listeners_cnt; i++) listeners[i](CTLE_ABORT);
+ args_copy = NULL;
}
memset(&current_client, 0, sizeof(current_client));
current_cache = NULL;
cache_miss_cnt = 0;
def_channel = NULL;
}
+ if (args_copy != NULL) loc_free(args_copy);
}
void cache_enter(CacheClient * client, Channel * channel, void * args, size_t args_size) {
@@ -164,7 +167,6 @@ void cache_exit(void) {
assert(current_client.client != NULL);
if (cache_miss_cnt > 0) exception(ERR_CACHE_MISS);
for (i = 0; i < listeners_cnt; i++) listeners[i](CTLE_COMMIT);
- if (current_client.args_copy) loc_free(current_client.args);
memset(&current_client, 0, sizeof(current_client));
current_cache = NULL;
cache_miss_cnt = 0;

Back to the top