Commit 05e4a87c authored by Sergey Vojtovich's avatar Sergey Vojtovich

A better fix for edd7e7c8

parent cb4da5da
......@@ -110,7 +110,7 @@ static char *directory_file_name (char * dst, const char *src)
MY_DIR *my_dir(const char *path, myf MyFlags)
{
MY_DIR_HANDLE *dirh= 0;
MY_DIR_HANDLE *dirh;
FILEINFO finfo;
DIR *dirp;
struct dirent *dp;
......@@ -123,10 +123,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
tmp_file= directory_file_name(tmp_path, path);
if (!(dirp= opendir(tmp_path)))
goto error;
{
my_errno= errno;
goto err_open;
}
if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL)))
goto error;
goto err_alloc;
if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
......@@ -180,12 +183,11 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_RETURN(&dirh->dir);
error:
my_errno=errno;
if (dirp)
(void) closedir(dirp);
if (dirh)
my_dirend(&dirh->dir);
error:
my_dirend(&dirh->dir);
err_alloc:
(void) closedir(dirp);
err_open:
if (MyFlags & (MY_FAE | MY_WME))
my_error(EE_DIR, MYF(ME_BELL | ME_WAITTANG), path, my_errno);
DBUG_RETURN(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