diff options
Diffstat (limited to 'mysys/my_lib.c')
-rw-r--r-- | mysys/my_lib.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 31fc68b871f..c40b75e1faf 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -109,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; @@ -122,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, @@ -179,11 +183,11 @@ MY_DIR *my_dir(const char *path, myf MyFlags) DBUG_RETURN(&dirh->dir); - error: - my_errno=errno; - if (dirp) - (void) closedir(dirp); +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); |