From c29a016ca6b171fed2fb8906e7e417917f010b59 Mon Sep 17 00:00:00 2001 From: Cong Date: Mon, 12 Feb 2018 10:51:06 +1100 Subject: Fix clang-tidy malloc 0 warning (fixes #56) Fixes potential invalid memory write bug, on platforms that return non-`NULL` for `malloc(0)`. --- tinydir.h | 4 ++-- 1 file 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; } -- cgit v1.2.3