Skip to content

Commit

Permalink
fix dangling pointers left when deleting reports
Browse files Browse the repository at this point in the history
  • Loading branch information
tony2001 committed Mar 24, 2016
1 parent 40178e8 commit df7b7c2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ha_pinba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ static inline void pinba_table_to_report_dtor(const char *table_name) /* {{{ */
}

tables = (pinba_report_tables *)pinba_map_get(D->reports_to_tables, index);
free(index);
if (!tables) {
/* we're not aware of a report until you do a SELECT from it, so it's ok */
pthread_mutex_unlock(&D->share_mutex);
Expand All @@ -718,7 +717,6 @@ static inline void pinba_table_to_report_dtor(const char *table_name) /* {{{ */
/* this is also kind of ok, since we actually create reports only when there is any data */
return;
}
pthread_mutex_unlock(&D->share_mutex);

std = tables->std;

Expand All @@ -727,6 +725,9 @@ static inline void pinba_table_to_report_dtor(const char *table_name) /* {{{ */
/* destroy the report */
pthread_rwlock_unlock(&std->lock);

pinba_map_delete(D->reports_to_tables, index);
free(index);

switch (std->report_kind) {
case PINBA_BASE_REPORT_KIND: {
pinba_report *report = (pinba_report *)std;
Expand All @@ -748,6 +749,7 @@ static inline void pinba_table_to_report_dtor(const char *table_name) /* {{{ */
/* unlock and go ahead */
pthread_rwlock_unlock(&std->lock);
}
pthread_mutex_unlock(&D->share_mutex);
return;
}
/* }}} */
Expand Down

0 comments on commit df7b7c2

Please sign in to comment.