diff --git a/logger.c b/logger.c index 37d0d631..bcf7c682 100644 --- a/logger.c +++ b/logger.c @@ -397,6 +397,9 @@ static int LoggerMakeDir(char *path) return 0; /* mkdir failed */ snprintf(buffer, sizeof buffer, "%s", path); lpath = strlen(buffer); + /* Discard any trailing slash characters */ + while (lpath > 0 && buffer[lpath - 1] == '/') + buffer[--lpath] = '\0'; do { slash = strrchr(buffer, '/'); if (!slash) diff --git a/logsetup.c b/logsetup.c index a8394b97..aceb023e 100644 --- a/logsetup.c +++ b/logsetup.c @@ -118,6 +118,11 @@ static int LogSetup(SConnection * pCon, SicsInterp * pSics, void *pData, LoggerChange(logger, period, name); } else { logger = LoggerMake(name, period, !numeric); + /* If that failed, we cannot continue - it crashes in the callback */ + if (logger == NULL) { + SCPrintf(pCon, eError, "ERROR: logger %s not created", argv[1]); + return 0; + } LoggerSetNumeric(logger, numeric); SetHdbProperty(node, "logger_name", name); cb = MakeHipadabaCallback(LoggerUpdateCallback, logger,