Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ static int zlog_rule_parse_path(char *path_start, /* start with a " */
{
char *p, *q;
size_t len;
zlog_spec_t *a_spec;
zc_arraylist_t *specs;
zlog_spec_t *a_spec = NULL;
zc_arraylist_t *specs = NULL;

p = path_start + 1;

Expand Down Expand Up @@ -550,29 +550,32 @@ static int zlog_rule_parse_path(char *path_start, /* start with a " */
}

specs = zc_arraylist_new((zc_arraylist_del_fn)zlog_spec_del);
if (!path_specs) {
if (specs == NULL) {
zc_error("zc_arraylist_new fail");
return -1;
}
}

for (p = path_str; *p != '\0'; p = q) {
a_spec = zlog_spec_new(p, &q, time_cache_count);
if (!a_spec) {
zc_error("zlog_spec_new fail");
goto err;
}


if (zc_arraylist_add(specs, a_spec)) {
zc_error("zc_arraylist_add fail");
zlog_spec_del(a_spec);
goto err;
}
a_spec = NULL;
}

*path_specs = specs;
return 0;
err:
if (specs) zc_arraylist_del(specs);
if (a_spec) zlog_spec_del(a_spec);
if (a_spec) zlog_spec_del(a_spec);
return -1;
}

Expand Down
11 changes: 11 additions & 0 deletions src/spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,19 @@ static int zlog_spec_write_level_lowercase(zlog_spec_t * a_spec, zlog_thread_t *
static int zlog_spec_write_level_uppercase(zlog_spec_t * a_spec, zlog_thread_t * a_thread, zlog_buf_t * a_buf)
{
zlog_level_t *a_level;
if (a_thread == NULL ||
a_thread->event == NULL ||
a_thread->event->level == NULL) {
zlog_spec_write_error(a_spec, "zlog_spec_write_level_uppercase: Event or level object is NULL. Cannot process.");
return -1;
}


a_level = zlog_level_list_get(zlog_env_conf->levels, a_thread->event->level);
if (a_level == NULL) {
zlog_spec_write_error(a_spec, "zlog_spec_write_level_uppercase: Invalid log level returned for '%s'.", a_thread->event->level? a_thread->event->level : "NULL_LEVEL_STRING");
return -1;
}
return zlog_buf_append(a_buf, a_level->str_uppercase, a_level->str_len);
}

Expand Down