From 32278efab1839b19d0becfbae465d2afefd4144c Mon Sep 17 00:00:00 2001 From: Cong Date: Sat, 2 Dec 2023 23:27:11 +1100 Subject: [PATCH] Check make_temp_dir output --- tests/file_open_test.c | 1 + tests/util.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/file_open_test.c b/tests/file_open_test.c index 11b1431..9f8f3e6 100644 --- a/tests/file_open_test.c +++ b/tests/file_open_test.c @@ -21,6 +21,7 @@ FEATURE(file_open, "File open") GIVEN("a file with a long filename in a folder with a long filename") char folder[4096]; make_temp_dir("temp_dir_", folder); + ASSERT(strlen(folder) > 0, 1); strcat(folder, "/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); mkdir(folder, 0700); strcat(folder, "/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); diff --git a/tests/util.c b/tests/util.c index 315d95b..c200871 100644 --- a/tests/util.c +++ b/tests/util.c @@ -43,6 +43,9 @@ void make_temp_dir(const char *prefix, char *out) } #else sprintf(out, "%sXXXXXX", prefix); - (void)mkdtemp(out); + if (mkdtemp(out) == NULL) + { + out[0] = '\0'; + } #endif }