diff options
author | Pavan Deolasee | 2016-05-06 12:36:37 +0000 |
---|---|---|
committer | Pavan Deolasee | 2016-10-18 10:05:07 +0000 |
commit | 166b0280b0c8ac61c9a70bed5aaa83c98f9fc32c (patch) | |
tree | e209447c142049586d441606c12bf64774f568bd | |
parent | 47c7bcd9ac699311c7d2df04793fced7f69620c8 (diff) |
Fix a memory leak in GTM proxy
When two lists are concatnated, we might leak header of the second list since
only the list cells are concatnated. We must be careful not to free the list if
list_concat returned the to-be-concatnated list as-is.
-rw-r--r-- | src/gtm/proxy/proxy_main.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index 871280fa89..e03e3e8b34 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -2441,6 +2441,14 @@ GTMProxy_ProcessPendingCommands(GTMProxy_ThreadInfo *thrinfo) */ thrinfo->thr_processed_commands = gtm_list_concat(thrinfo->thr_processed_commands, thrinfo->thr_pending_commands[ii]); + /* + * Free the list header of the second list, unless + * gtm_list_concat actually returned the second list as-is + * because the first list was empty + */ + if ((thrinfo->thr_processed_commands != thrinfo->thr_pending_commands[ii]) && + (thrinfo->thr_pending_commands[ii] != gtm_NIL)) + pfree(thrinfo->thr_pending_commands[ii]); thrinfo->thr_pending_commands[ii] = gtm_NIL; break; @@ -2472,6 +2480,14 @@ GTMProxy_ProcessPendingCommands(GTMProxy_ThreadInfo *thrinfo) */ thrinfo->thr_processed_commands = gtm_list_concat(thrinfo->thr_processed_commands, thrinfo->thr_pending_commands[ii]); + /* + * Free the list header of the second list, unless + * gtm_list_concat actually returned the second list as-is + * because the first list was empty + */ + if ((thrinfo->thr_processed_commands != thrinfo->thr_pending_commands[ii]) && + (thrinfo->thr_pending_commands[ii] != gtm_NIL)) + pfree(thrinfo->thr_pending_commands[ii]); thrinfo->thr_pending_commands[ii] = gtm_NIL; break; @@ -2506,6 +2522,14 @@ GTMProxy_ProcessPendingCommands(GTMProxy_ThreadInfo *thrinfo) */ thrinfo->thr_processed_commands = gtm_list_concat(thrinfo->thr_processed_commands, thrinfo->thr_pending_commands[ii]); + /* + * Free the list header of the second list, unless + * gtm_list_concat actually returned the second list as-is + * because the first list was empty + */ + if ((thrinfo->thr_processed_commands != thrinfo->thr_pending_commands[ii]) && + (thrinfo->thr_pending_commands[ii] != gtm_NIL)) + pfree(thrinfo->thr_pending_commands[ii]); thrinfo->thr_pending_commands[ii] = gtm_NIL; break; @@ -2537,6 +2561,14 @@ GTMProxy_ProcessPendingCommands(GTMProxy_ThreadInfo *thrinfo) */ thrinfo->thr_processed_commands = gtm_list_concat(thrinfo->thr_processed_commands, thrinfo->thr_pending_commands[ii]); + /* + * Free the list header of the second list, unless + * gtm_list_concat actually returned the second list as-is + * because the first list was empty + */ + if ((thrinfo->thr_processed_commands != thrinfo->thr_pending_commands[ii]) && + (thrinfo->thr_pending_commands[ii] != gtm_NIL)) + pfree(thrinfo->thr_pending_commands[ii]); thrinfo->thr_pending_commands[ii] = gtm_NIL; break; |