Skip to content

Commit edd7e7c

Browse files
committed
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.
1 parent b11ff3d commit edd7e7c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mysys/my_lib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2008, 2020, MariaDB Corporation.
23
34
This program is free software; you can redistribute it and/or modify
45
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)
183184
my_errno=errno;
184185
if (dirp)
185186
(void) closedir(dirp);
186-
my_dirend(&dirh->dir);
187+
if (dirh)
188+
my_dirend(&dirh->dir);
187189
if (MyFlags & (MY_FAE | MY_WME))
188190
my_error(EE_DIR, MYF(ME_BELL | ME_WAITTANG), path, my_errno);
189191
DBUG_RETURN(NULL);

0 commit comments

Comments
 (0)