Skip to content

Commit

Permalink
Fixed memory bug where deallocated memory was being accessed after it…
Browse files Browse the repository at this point in the history
… was released back to the system.
  • Loading branch information
Michael Brockus committed Feb 19, 2019
1 parent ccf8c36 commit aaccc0b
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void zlog_buf_del(zlog_buf_t * a_buf)
{
//zc_assert(a_buf,);
if (a_buf->start) free(a_buf->start);
free(a_buf);
zc_debug("zlog_buf_del[%p]", a_buf);
free(a_buf);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/category.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void zlog_category_del(zlog_category_t * a_category)
{
zc_assert(a_category,);
if (a_category->fit_rules) zc_arraylist_del(a_category->fit_rules);
free(a_category);
zc_debug("zlog_category_del[%p]", a_category);
free(a_category);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void zlog_event_del(zlog_event_t * a_event)
{
zc_assert(a_event,);
if (a_event->time_caches) free(a_event->time_caches);
free(a_event);
zc_debug("zlog_event_del[%p]", a_event);
free(a_event);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void zlog_format_del(zlog_format_t * a_format)
if (a_format->pattern_specs) {
zc_arraylist_del(a_format->pattern_specs);
}
free(a_format);
zc_debug("zlog_format_del[%p]", a_format);
free(a_format);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void zlog_level_profile(zlog_level_t *a_level, int flag)
void zlog_level_del(zlog_level_t *a_level)
{
zc_assert(a_level,);
free(a_level);
zc_debug("zlog_level_del[%p]", a_level);
free(a_level);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/mdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ void zlog_mdc_del(zlog_mdc_t * a_mdc)
{
zc_assert(a_mdc,);
if (a_mdc->tab) zc_hashtable_del(a_mdc->tab);
free(a_mdc);
zc_debug("zlog_mdc_del[%p]", a_mdc);
free(a_mdc);
return;
}

static void zlog_mdc_kv_del(zlog_mdc_kv_t * a_mdc_kv)
{
free(a_mdc_kv);
zc_debug("zlog_mdc_kv_del[%p]", a_mdc_kv);
free(a_mdc_kv);
}

static zlog_mdc_kv_t *zlog_mdc_kv_new(const char *key, const char *value)
Expand Down
2 changes: 1 addition & 1 deletion src/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void zlog_record_profile(zlog_record_t *a_record, int flag)
void zlog_record_del(zlog_record_t *a_record)
{
zc_assert(a_record,);
free(a_record);
zc_debug("zlog_record_del[%p]", a_record);
free(a_record);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rotater.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void zlog_rotater_del(zlog_rotater_t *a_rotater)
zc_error("pthread_mutex_destroy fail, errno[%d]", errno);
}

free(a_rotater);
zc_debug("zlog_rotater_del[%p]", a_rotater);
free(a_rotater);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,8 @@ void zlog_rule_del(zlog_rule_t * a_rule)
zc_arraylist_del(a_rule->archive_specs);
a_rule->archive_specs = NULL;
}
free(a_rule);
zc_debug("zlog_rule_del[%p]", a_rule);
free(a_rule);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static int zlog_spec_write_usrmsg(zlog_spec_t * a_spec, zlog_thread_t * a_thread
}

line_offset = 0;
byte_offset = 0;
//byte_offset = 0;

while (1) {
unsigned char c;
Expand Down Expand Up @@ -447,8 +447,8 @@ static int zlog_spec_parse_print_fmt(zlog_spec_t * a_spec)
void zlog_spec_del(zlog_spec_t * a_spec)
{
zc_assert(a_spec,);
free(a_spec);
zc_debug("zlog_spec_del[%p]", a_spec);
free(a_spec);
}

/* a spec may consist of
Expand Down
2 changes: 1 addition & 1 deletion src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void zlog_thread_del(zlog_thread_t * a_thread)
if (a_thread->msg_buf)
zlog_buf_del(a_thread->msg_buf);

free(a_thread);
zc_debug("zlog_thread_del[%p]", a_thread);
free(a_thread);
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/zc_arraylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static int zc_arraylist_expand_inner(zc_arraylist_t * a_list, int max)
tmp = realloc(a_list->array, new_size * sizeof(void *));
if (!tmp) {
zc_error("realloc fail, errno[%d]", errno);
free(a_list->array);
return -1;
}
a_list->array = (void **)tmp;
Expand Down

0 comments on commit aaccc0b

Please sign in to comment.