Navigation Menu

Skip to content

Commit

Permalink
storage mariadb: fix a memory leak for mroonga_log_file
Browse files Browse the repository at this point in the history
A variable that has PLUGIN_VAR_MEMALLOC flag should be freed on
MariaDB.
  • Loading branch information
kou committed Sep 25, 2013
1 parent bd9dc92 commit 037a7f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ha_mroonga.cpp
Expand Up @@ -605,11 +605,12 @@ static void mrn_log_file_update(THD *thd, struct st_mysql_sys_var *var,
}
}

const char *new_log_file_name;
if (log_file_open_errno == 0) {
GRN_LOG(&ctx, GRN_LOG_NOTICE,
"log file is changed: <%s> -> <%s>",
*old_value_ptr, new_value);
*old_value_ptr = my_strdup(new_value, MYF(MY_WME));
new_log_file_name = new_value;
} else {
if (mrn_log_file) {
GRN_LOG(&ctx, GRN_LOG_ERROR,
Expand All @@ -621,8 +622,15 @@ static void mrn_log_file_update(THD *thd, struct st_mysql_sys_var *var,
"log file can't be opened: <%s>: <%s>",
new_value, strerror(log_file_open_errno));
}
*old_value_ptr = my_strdup(*old_value_ptr, MYF(MY_WME));
new_log_file_name = *old_value_ptr;
}
#ifdef MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR
char *old_log_file_name = *old_value_ptr;
*old_value_ptr = my_strdup(new_log_file_name, MYF(MY_WME));
my_free(old_log_file_name, MYF(0));
#else
*old_value_ptr = new_log_file_name;
#endif
}
grn_ctx_fin(&ctx);

Expand Down

0 comments on commit 037a7f6

Please sign in to comment.