From f00de26be1c7b23b2be797a327a27e5740ba1e0a Mon Sep 17 00:00:00 2001 From: Hinko Kocevar Date: Thu, 15 Aug 2024 10:47:02 +0200 Subject: [PATCH] directory path name is free'd before it is used in testAbort() --- modules/database/test/ioc/db/dbStaticTest.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/database/test/ioc/db/dbStaticTest.c b/modules/database/test/ioc/db/dbStaticTest.c index 61d29e9cd..0ead11803 100644 --- a/modules/database/test/ioc/db/dbStaticTest.c +++ b/modules/database/test/ioc/db/dbStaticTest.c @@ -13,6 +13,7 @@ #include #include #include +#include static void testEntryRemoved(const char *pv) @@ -337,6 +338,7 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(dbStaticTest) { const char *ldir; + char *ldirDup; FILE *fp = NULL; testPlan(340); @@ -349,20 +351,24 @@ MAIN(dbStaticTest) if(!fp) { testAbort("Unable to read dbStaticTest.db"); } + ldirDup = epicsStrDup(ldir); if(dbReadDatabaseFP(&pdbbase, fp, NULL, NULL)) { testAbort("Unable to load %s%sdbStaticTest.db", - ldir, OSI_PATH_LIST_SEPARATOR); + ldirDup, OSI_PATH_LIST_SEPARATOR); } + free(ldirDup); dbPath(pdbbase,"." OSI_PATH_LIST_SEPARATOR ".."); ldir = dbOpenFile(pdbbase, "dbStaticTestRemove.db", &fp); if(!fp) { testAbort("Unable to read dbStaticTestRemove.db"); } + ldirDup = epicsStrDup(ldir); if(dbReadDatabaseFP(&pdbbase, fp, NULL, NULL)) { testAbort("Unable to load %s%sdbStaticTestRemove.db", - ldir, OSI_PATH_LIST_SEPARATOR); + ldirDup, OSI_PATH_LIST_SEPARATOR); } + free(ldirDup); testWrongAliasRecord("dbStaticTestAlias1.db"); testWrongAliasRecord("dbStaticTestAlias2.db");