Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCong <congusbongus@gmail.com>2018-02-12 02:51:06 +0300
committerGitHub <noreply@github.com>2018-02-12 02:51:06 +0300
commitc29a016ca6b171fed2fb8906e7e417917f010b59 (patch)
treea55c12095c44e66199d941ed37e863cfaa3c4c6f
parent3aae9224376b5e1a23fd824f19d9501162620b53 (diff)
Fix clang-tidy malloc 0 warning (fixes #56)
Fixes potential invalid memory write bug, on platforms that return non-`NULL` for `malloc(0)`.
-rw-r--r--tinydir.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/tinydir.h b/tinydir.h
index eb34399..ca71571 100644
--- a/tinydir.h
+++ b/tinydir.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2017, tinydir authors:
+Copyright (c) 2013-2018, tinydir authors:
- Cong Xu
- Lautis Sun
- Baudouin Feildel
@@ -365,7 +365,7 @@ int tinydir_open_sorted(tinydir_dir *dir, const _tinydir_char_t *path)
}
tinydir_close(dir);
- if (tinydir_open(dir, path) == -1)
+ if (n_files == 0 || tinydir_open(dir, path) == -1)
{
return -1;
}