[LTP] [PATCH] lib/tst_tmpdir: tst_get_tmpdir() add error handing
zhanglianjie
zhanglianjie@uniontech.com
Fri Aug 6 05:21:31 CEST 2021
Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com>
diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index 0c39eb89f..f006e4893 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -108,12 +108,18 @@ int tst_tmpdir_created(void)
char *tst_get_tmpdir(void)
{
+ char *ret = NULL;
+
if (TESTDIR == NULL) {
tst_brkm(TBROK, NULL, "you must call tst_tmpdir() first");
return NULL;
}
- return strdup(TESTDIR);
+ ret = strdup(TESTDIR);
+ if (!ret)
+ tst_brkm(TBROK, NULL, "strdup() failed");
+
+ return ret;
}
const char *tst_get_startwd(void)
--
2.20.1
More information about the ltp
mailing list