Fix segfault when calling dbLoadRecords after iocInit
This fixes lp:1829919.
This commit is contained in:
+12
-3
@@ -730,9 +730,18 @@ int dbLoadDatabase(const char *file, const char *path, const char *subs)
|
||||
int dbLoadRecords(const char* file, const char* subs)
|
||||
{
|
||||
int status = dbReadDatabase(&pdbbase, file, 0, subs);
|
||||
|
||||
if (!status && dbLoadRecordsHook)
|
||||
dbLoadRecordsHook(file, subs);
|
||||
switch(status)
|
||||
{
|
||||
case 0:
|
||||
if(dbLoadRecordsHook)
|
||||
dbLoadRecordsHook(file, subs);
|
||||
break;
|
||||
case -2:
|
||||
errlogPrintf("dbLoadRecords: failed to load %s - cannot load records after running iocBuild!\n", file);
|
||||
break;
|
||||
default:
|
||||
errlogPrintf("dbLoadRecords: failed to load %s\n", file);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "dbmf.h"
|
||||
@@ -115,6 +116,12 @@ typedef struct tempListNode {
|
||||
static ELLLIST tempList = ELLLIST_INIT;
|
||||
static void *freeListPvt = NULL;
|
||||
static int duplicate = FALSE;
|
||||
static bool dbLoadRecordsAllowed = true;
|
||||
|
||||
void disableDbLoadRecords()
|
||||
{
|
||||
dbLoadRecordsAllowed = false;
|
||||
}
|
||||
|
||||
static void yyerrorAbort(char *str)
|
||||
{
|
||||
@@ -215,6 +222,9 @@ static long dbReadCOM(DBBASE **ppdbbase,const char *filename, FILE *fp,
|
||||
char *penv;
|
||||
char **macPairs;
|
||||
|
||||
if(!dbLoadRecordsAllowed)
|
||||
return -2;
|
||||
|
||||
if(*ppdbbase == 0) *ppdbbase = dbAllocBase();
|
||||
pdbbase = *ppdbbase;
|
||||
if(path && strlen(path)>0) {
|
||||
|
||||
@@ -8,12 +8,19 @@
|
||||
\*************************************************************************/
|
||||
|
||||
#include "iocsh.h"
|
||||
#include "initHooks.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbStaticIocRegister.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbStaticPvt.h"
|
||||
|
||||
static void dbStaticIocRegisterInitHook(initHookState state)
|
||||
{
|
||||
if(state == initHookAtIocBuild)
|
||||
disableDbLoadRecords();
|
||||
}
|
||||
|
||||
/* common arguments */
|
||||
|
||||
static const iocshArg argPdbbase = { "pdbbase", iocshArgPdbbase};
|
||||
@@ -153,6 +160,7 @@ static void dbReportDeviceConfigCallFunc(const iocshArgBuf *args)
|
||||
|
||||
void dbStaticIocRegister(void)
|
||||
{
|
||||
initHookRegister(dbStaticIocRegisterInitHook);
|
||||
iocshRegister(&dbDumpPathFuncDef, dbDumpPathCallFunc);
|
||||
iocshRegister(&dbDumpRecordFuncDef, dbDumpRecordCallFunc);
|
||||
iocshRegister(&dbDumpMenuFuncDef, dbDumpMenuCallFunc);
|
||||
|
||||
@@ -25,6 +25,7 @@ dbDeviceMenu *dbGetDeviceMenu(DBENTRY *pdbentry);
|
||||
void dbFreeLinkContents(struct link *plink);
|
||||
void dbFreePath(DBBASE *pdbbase);
|
||||
int dbIsMacroOk(DBENTRY *pdbentry);
|
||||
void disableDbLoadRecords();
|
||||
|
||||
/*The following routines have different versions for run-time no-run-time*/
|
||||
long dbAllocRecord(DBENTRY *pdbentry,const char *precordName);
|
||||
|
||||
Reference in New Issue
Block a user