Skip to content

Commit

Permalink
Port: Fix bug 1588344 (Memory leak in non-existing defaults file hand…
Browse files Browse the repository at this point in the history
…ling)

Summary:
Port the following commit from percona server:
percona/percona-server@4344909

Fix bug 1588344 (Memory leak in non-existing defaults file handling)

Ensure that dynamic array args is freed on error exits in
my_load_defaults.

Reviewed By: gunnarku

Differential Revision: D5196926

fbshipit-source-id: 60f5267
  • Loading branch information
tianx authored and facebook-github-bot committed Jun 7, 2017
1 parent 7d61808 commit 7ae738d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mysys_ssl/my_default.cc
Expand Up @@ -663,6 +663,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
&args_used, handle_default_option,
(void *) &ctx, dirs, false, found_no_defaults)))
{
delete_dynamic(&args);
free_root(&alloc,MYF(0));
DBUG_RETURN(error);
}
Expand All @@ -675,6 +676,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
handle_default_option, (void *) &ctx,
dirs, true, found_no_defaults)))
{
delete_dynamic(&args);
free_root(&alloc, MYF(0));
DBUG_RETURN(error);
}
Expand All @@ -685,7 +687,10 @@ int my_load_defaults(const char *conf_file, const char **groups,
*/
if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
(args.elements + *argc + 1 + args_sep) *sizeof(char*))))
{
delete_dynamic(&args);
goto err;
}
res= (char**) (ptr+sizeof(alloc));

/* copy name + found arguments + command line arguments to new array */
Expand Down

0 comments on commit 7ae738d

Please sign in to comment.