summaryrefslogtreecommitdiff
path: root/mysys/my_lib.c
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2020-03-28 19:11:24 +0300
committerEugene Kosov <claprix@yandex.ru>2020-03-31 00:44:01 +0300
commitedd7e7c85d301c7f8c4ecc1f38dcb1151a11b792 (patch)
tree34e07e1f43b98d4472aea75087f6cb252a619d4b /mysys/my_lib.c
parentb11ff3d49581d9e7b6f8b990f08e85e4d6384418 (diff)
downloadmariadb-git-edd7e7c85d301c7f8c4ecc1f38dcb1151a11b792.tar.gz
MDEV-22069 UBSAN: runtime error: member access within null pointer of type 'MY_DIR_HANDLE' in mysys/my_lib.c
This is an error handling bug. When opendir() fails dirh is NULL and we shouldn't try to free it.
Diffstat (limited to 'mysys/my_lib.c')
-rw-r--r--mysys/my_lib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 31fc68b871f..da239a3fdab 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
@@ -183,7 +184,8 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
my_errno=errno;
if (dirp)
(void) closedir(dirp);
- my_dirend(&dirh->dir);
+ if (dirh)
+ my_dirend(&dirh->dir);
if (MyFlags & (MY_FAE | MY_WME))
my_error(EE_DIR, MYF(ME_BELL | ME_WAITTANG), path, my_errno);
DBUG_RETURN(NULL);