diff options
author | Cong <congusbongus@gmail.com> | 2018-02-12 02:51:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-12 02:51:06 +0300 |
commit | c29a016ca6b171fed2fb8906e7e417917f010b59 (patch) | |
tree | a55c12095c44e66199d941ed37e863cfaa3c4c6f | |
parent | 3aae9224376b5e1a23fd824f19d9501162620b53 (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.h | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; } |