Commit 73ae71a8 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

Bugfix for segfault in mysql with embedded library

parent e2baf777
...@@ -174,7 +174,8 @@ void load_defaults(const char *conf_file, const char **groups, ...@@ -174,7 +174,8 @@ void load_defaults(const char *conf_file, const char **groups,
res= (char**) (ptr+sizeof(alloc)); res= (char**) (ptr+sizeof(alloc));
/* copy name + found arguments + command line arguments to new array */ /* copy name + found arguments + command line arguments to new array */
res[0]=argv[0][0]; res[0]=*argc ? argv[0][0] : "";
memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*));
/* Skipp --defaults-file and --defaults-extra-file */ /* Skipp --defaults-file and --defaults-extra-file */
(*argc)-= args_used; (*argc)-= args_used;
...@@ -187,6 +188,7 @@ void load_defaults(const char *conf_file, const char **groups, ...@@ -187,6 +188,7 @@ void load_defaults(const char *conf_file, const char **groups,
--*argc; ++*argv; /* skipp argument */ --*argc; ++*argv; /* skipp argument */
} }
if (*argc)
memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1),
(*argc-1)*sizeof(char*)); (*argc-1)*sizeof(char*));
res[args.elements+ *argc]=0; /* last null */ res[args.elements+ *argc]=0; /* last null */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment