profiling: fix memory leaks

pull/2534/head
Victor Julien 8 years ago
parent 6e876182d7
commit addf64f1f7

@ -63,7 +63,7 @@ typedef struct SCProfileKeywordDetectCtx_ {
static int profiling_keywords_output_to_file = 0;
int profiling_keyword_enabled = 0;
__thread int profiling_keyword_entered = 0;
static char *profiling_file_name = "";
static char profiling_file_name[PATH_MAX];
static const char *profiling_file_mode = "a";
void SCProfilingKeywordsGlobalInit(void)
@ -80,12 +80,8 @@ void SCProfilingKeywordsGlobalInit(void)
char *log_dir;
log_dir = ConfigGetLogDirectory();
profiling_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
snprintf(profiling_file_name, PATH_MAX, "%s/%s", log_dir, filename);
snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s",
log_dir, filename);
const char *v = ConfNodeLookupChildValue(conf, "append");
if (v == NULL || ConfValIsTrue(v)) {

@ -64,7 +64,7 @@ typedef struct SCProfileSghDetectCtx_ {
static int profiling_sghs_output_to_file = 0;
int profiling_sghs_enabled = 0;
static char *profiling_file_name = "";
static char profiling_file_name[PATH_MAX];
static const char *profiling_file_mode = "a";
#ifdef HAVE_LIBJANSSON
static int profiling_rulegroup_json = 0;
@ -84,12 +84,8 @@ void SCProfilingSghsGlobalInit(void)
char *log_dir;
log_dir = ConfigGetLogDirectory();
profiling_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
snprintf(profiling_file_name, PATH_MAX, "%s/%s", log_dir, filename);
snprintf(profiling_file_name, sizeof(profiling_file_name),
"%s/%s", log_dir, filename);
const char *v = ConfNodeLookupChildValue(conf, "append");
if (v == NULL || ConfValIsTrue(v)) {

@ -79,7 +79,7 @@ typedef struct SCProfileSummary_ {
extern int profiling_output_to_file;
int profiling_rules_enabled = 0;
static char *profiling_file_name = "";
static char profiling_file_name[PATH_MAX] = "";
static const char *profiling_file_mode = "a";
#ifdef HAVE_LIBJANSSON
static int profiling_rule_json = 0;
@ -165,12 +165,8 @@ void SCProfilingRulesGlobalInit(void)
char *log_dir;
log_dir = ConfigGetLogDirectory();
profiling_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
snprintf(profiling_file_name, PATH_MAX, "%s/%s", log_dir, filename);
snprintf(profiling_file_name, sizeof(profiling_file_name),
"%s/%s", log_dir, filename);
const char *v = ConfNodeLookupChildValue(conf, "append");
if (v == NULL || ConfValIsTrue(v)) {

@ -102,14 +102,14 @@ static SCProfilePacketData prefilter6[256][256];
struct ProfileProtoRecords packet_profile_flowworker_data[PROFILE_FLOWWORKER_SIZE];
int profiling_packets_enabled = 0;
int profiling_packets_csv_enabled = 0;
int profiling_output_to_file = 0;
int profiling_packets_output_to_file = 0;
char *profiling_file_name;
char *profiling_packets_file_name;
char *profiling_csv_file_name;
const char *profiling_packets_file_mode = "a";
static int profiling_packets_csv_enabled = 0;
static int profiling_packets_output_to_file = 0;
static char *profiling_file_name;
static char profiling_packets_file_name[PATH_MAX];
static char *profiling_csv_file_name;
static const char *profiling_packets_file_mode = "a";
static int rate = 1;
static SC_ATOMIC_DECLARE(uint64_t, samples);
@ -187,13 +187,8 @@ SCProfilingInit(void)
char *log_dir;
log_dir = ConfigGetLogDirectory();
profiling_packets_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_packets_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
snprintf(profiling_packets_file_name, PATH_MAX, "%s/%s", log_dir, filename);
snprintf(profiling_packets_file_name, sizeof(profiling_packets_file_name),
"%s/%s", log_dir, filename);
const char *v = ConfNodeLookupChildValue(conf, "append");
if (v == NULL || ConfValIsTrue(v)) {

Loading…
Cancel
Save