From 623015eb0db1f0ab695a2c787bbb91bb76546c86 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 24 Mar 2016 11:07:09 +0300 Subject: [PATCH] (mc_closedir): fix NULL dereference. Signed-off-by: Andrew Borodin --- lib/vfs/interface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index 064b398b0..4d2092e79 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -515,10 +515,15 @@ mc_readdir (DIR * dirp) int mc_closedir (DIR * dirp) { - int handle = *(int *) dirp; + int handle; struct vfs_class *vfs; int result = -1; + if (dirp == NULL) + return result; + + handle = *(int *) dirp; + vfs = vfs_class_find_by_handle (handle); if (vfs != NULL) {