summaryrefslogtreecommitdiff
path: root/mysys/my_lib.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2020-04-01 16:25:07 +0400
committerSergey Vojtovich <svoj@mariadb.org>2020-04-01 16:25:07 +0400
commit05e4a87c8b074910f4bbf2b6a666a670764c4f89 (patch)
tree7145f184f6e9f6a2883724bb07826dbb3080f60f /mysys/my_lib.c
parentcb4da5da74b7a6f2e7c4f4ed1b0e5affe45fe2a2 (diff)
downloadmariadb-git-05e4a87c8b074910f4bbf2b6a666a670764c4f89.tar.gz
A better fix for edd7e7c
Diffstat (limited to 'mysys/my_lib.c')
-rw-r--r--mysys/my_lib.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index da239a3fdab..c40b75e1faf 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -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);