diff --git a/src/util-debug-filters.c b/src/util-debug-filters.c index 43effe91ee..0dd8c2ca09 100644 --- a/src/util-debug-filters.c +++ b/src/util-debug-filters.c @@ -486,15 +486,15 @@ int SCLogPrintFGFilters() */ int SCLogMatchFDFilter(const char *function) { +#ifndef DEBUG + return 1; +#else + SCLogFDFilterThreadList *thread_list = NULL; // pid_t self = syscall(SYS_gettid); pthread_t self = pthread_self(); -#ifndef DEBUG - return 1; -#endif - if (sc_log_module_initialized != 1) { printf("Logging module not initialized. Call SCLogInitLogModule() " "first before using the debug API\n"); @@ -527,6 +527,8 @@ int SCLogMatchFDFilter(const char *function) SCMutexUnlock(&sc_log_fd_filters_tl_m); return 0; + +#endif /* #else - #ifndef DEBUG */ } /** @@ -591,8 +593,10 @@ int SCLogCheckFDFilterEntry(const char *function) return 1; } - if ( (thread_list_temp = SCMalloc(sizeof(SCLogFDFilterThreadList))) == NULL) + if ( (thread_list_temp = SCMalloc(sizeof(SCLogFDFilterThreadList))) == NULL) { + SCMutexUnlock(&sc_log_fd_filters_tl_m); return 0; + } memset(thread_list_temp, 0, sizeof(SCLogFDFilterThreadList)); thread_list_temp->t = self; @@ -705,8 +709,10 @@ int SCLogAddFDFilter(const char *function) curr = curr->next; } - if ( (temp = SCMalloc(sizeof(SCLogFDFilter))) == NULL) + if ( (temp = SCMalloc(sizeof(SCLogFDFilter))) == NULL) { + SCMutexUnlock(&sc_log_fd_filters_m); return -1; + } memset(temp, 0, sizeof(SCLogFDFilter)); if ( (temp->func = SCStrdup(function)) == NULL) { diff --git a/src/util-debug.c b/src/util-debug.c index 975f943462..4bf68adca9 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -580,11 +580,11 @@ static inline SCLogOPIfaceCtx *SCLogInitFileOPIface(const char *file, goto error; } - if ((iface_ctx->file = strdup(file)) == NULL) { + if ((iface_ctx->file = SCStrdup(file)) == NULL) { goto error; } - if ((iface_ctx->log_format = strdup(log_format)) == NULL) { + if ((iface_ctx->log_format = SCStrdup(log_format)) == NULL) { goto error; } @@ -593,17 +593,20 @@ static inline SCLogOPIfaceCtx *SCLogInitFileOPIface(const char *file, return iface_ctx; error: - if (iface_ctx->file != NULL) { - free((char *)iface_ctx->file); - iface_ctx->file = NULL; - } - if (iface_ctx->log_format != NULL) { - free((char *)iface_ctx->log_format); - iface_ctx->log_format = NULL; - } - if (iface_ctx->file_d != NULL) { - fclose(iface_ctx->file_d); - iface_ctx->file_d = NULL; + if (iface_ctx != NULL) { + if (iface_ctx->file != NULL) { + SCFree((char *)iface_ctx->file); + iface_ctx->file = NULL; + } + if (iface_ctx->log_format != NULL) { + SCFree((char *)iface_ctx->log_format); + iface_ctx->log_format = NULL; + } + if (iface_ctx->file_d != NULL) { + fclose(iface_ctx->file_d); + iface_ctx->file_d = NULL; + } + SCFree(iface_ctx); } return NULL; }