Commit 3c47f57f authored by unknown's avatar unknown

Memory allocation bug fixed

parent 44f15cae
...@@ -386,18 +386,18 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l ...@@ -386,18 +386,18 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l
cp= strmake(result, root, len); cp= strmake(result, root, len);
if (cp[-1] != FN_LIBCHAR) if (cp[-1] != FN_LIBCHAR)
*cp= FN_LIBCHAR; *cp++= FN_LIBCHAR;
ret= 1; ret= 1;
va_start(va, len); va_start(va, len);
subdir= (!(flags & MY_SEARCH_SELF)) ? va_arg(va, char *) : ""; subdir= (!(flags & MY_SEARCH_SELF)) ? va_arg(va, char *) : "";
while (ret && subdir) while (subdir)
{ {
MY_DIR *dir; MY_DIR *dir;
FILEINFO *match; FILEINFO *match;
char *cp1; char *cp1;
cp1= strnmov(cp + 1, subdir, len - (cp - result) - 1); cp1= strnmov(cp, subdir, len - (cp - result) - 1);
dir= my_dir(result, (flags & MY_ISDIR) ? MY_WANT_STAT : MYF(0)); dir= my_dir(result, (flags & MY_ISDIR) ? MY_WANT_STAT : MYF(0));
if (dir) if (dir)
...@@ -406,25 +406,20 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l ...@@ -406,25 +406,20 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l
sizeof(FILEINFO), (qsort_cmp)comp_names); sizeof(FILEINFO), (qsort_cmp)comp_names);
if (match) if (match)
{ {
if (!(flags & MY_PARENT)) ret= (flags & MY_ISDIR) ? !MY_S_ISDIR(match->mystat->st_mode) : 0;
{ if (!ret)
if (cp1[-1] != FN_LIBCHAR) {
if (cp1[-1] != FN_LIBCHAR)
*cp1++= FN_LIBCHAR; *cp1++= FN_LIBCHAR;
strnmov(cp1, name, len - (cp1 - result));
} if (!(flags & MY_PARENT))
else strnmov(cp1, name, len - (cp1 - result));
{ else
if (cp1[-1] == FN_LIBCHAR) *cp1= '\0';
--cp1;
while (*--cp1 == FN_LIBCHAR) my_dirend(dir);
{} break;
*++cp1= FN_LIBCHAR;
*++cp1= '\0';
} }
if (flags & MY_ISDIR)
ret= !MY_S_ISDIR(match->mystat->st_mode);
else
ret= 0;
} }
my_dirend(dir); my_dirend(dir);
} }
...@@ -484,7 +479,7 @@ int main(int argc, char **argv) ...@@ -484,7 +479,7 @@ int main(int argc, char **argv)
|| find_file(mysqld_name, basedir, MYF(0), path, sizeof(path), || find_file(mysqld_name, basedir, MYF(0), path, sizeof(path),
"bin", "libexec", NullS)) "bin", "libexec", NullS))
{ {
my_strdup((gptr)basedir, MYF(0)); my_free((gptr)basedir, MYF(0));
basedir= (char *)DEFAULT_MYSQL_HOME; basedir= (char *)DEFAULT_MYSQL_HOME;
} }
} }
......
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