diff options
author | monty@mysql.com <> | 2006-06-06 02:47:30 +0300 |
---|---|---|
committer | monty@mysql.com <> | 2006-06-06 02:47:30 +0300 |
commit | a703ff60c7d6fbc6fa1c3ef25167cbe85d852bf8 (patch) | |
tree | 95341607866eaeca795c9a1a4c4c0d94df862cfd /sql | |
parent | 430347f12622b98d4e87bc2c33934335f410029b (diff) | |
download | mariadb-git-a703ff60c7d6fbc6fa1c3ef25167cbe85d852bf8.tar.gz |
Fixed some issues found by valgrind
(one testcase, one memory leak and some accesses to not initialized memory)
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_berkeley.cc | 5 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 | ||||
-rw-r--r-- | sql/table.cc | 14 | ||||
-rw-r--r-- | sql/time.cc | 1 |
6 files changed, 19 insertions, 11 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 6f5f9f32e76..d8159a81f90 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -361,6 +361,7 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print) init_sql_alloc(&show_logs_root, BDB_LOG_ALLOC_BLOCK_SIZE, BDB_LOG_ALLOC_BLOCK_SIZE); *root_ptr= &show_logs_root; + all_logs= free_logs= 0; if ((error= db_env->log_archive(db_env, &all_logs, DB_ARCH_ABS | DB_ARCH_LOG)) || @@ -395,6 +396,10 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print) } } err: + if (all_logs) + free(all_logs); + if (free_logs) + free(free_logs); free_root(&show_logs_root,MYF(0)); *root_ptr= old_mem_root; DBUG_RETURN(error); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 94584755e86..0ede042da17 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -228,7 +228,7 @@ THD::THD() hash_clear(&handler_tables_hash); tmp_table=0; used_tables=0; - cuted_fields= sent_row_count= 0L; + cuted_fields= sent_row_count= row_count= 0L; limit_found_rows= 0; statement_id_counter= 0UL; #ifdef ERROR_INJECT_SUPPORT diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0ebaf90431c..94a2922eb33 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4178,7 +4178,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table) DBUG_RETURN(1); sch_table->field[7]->set_notnull(); - sch_table->field[7]->store(show_str.c_ptr(), show_str.length(), scs); + sch_table->field[7]->store(show_str.ptr(), show_str.length(), scs); LEX_STRING *ival= &interval_type_to_name[et.interval]; sch_table->field[8]->set_notnull(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index af2bf8231aa..a8c93b683b3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1385,7 +1385,7 @@ ev_schedule_time: EVERY_SYM expr interval String str(buff,(uint32) sizeof(buff), system_charset_info); String *str2= $2->val_str(&str); my_error(ER_WRONG_VALUE, MYF(0), "AT", - str2? str2->c_ptr():"NULL"); + str2? str2->c_ptr_safe():"NULL"); YYABORT; break; } @@ -1436,8 +1436,8 @@ ev_starts: /* empty */ char buff[20]; String str(buff,(uint32) sizeof(buff), system_charset_info); String *str2= $2->val_str(&str); - my_error(ER_WRONG_VALUE, MYF(0), "STARTS", str2? str2->c_ptr(): - NULL); + my_error(ER_WRONG_VALUE, MYF(0), "STARTS", + str2 ? str2->c_ptr_safe() : NULL); YYABORT; break; } diff --git a/sql/table.cc b/sql/table.cc index 39f1e1d620d..45db45b1ffd 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2392,26 +2392,28 @@ table_check_intact(TABLE *table, uint table_f_count, table_f_count, table->s->fields); } else + { /* moving from newer mysql to older one -> let's say not an error but - will check the definition afterwards. If a column was added at the end - then we don't care much since it's not in the middle. + will check the definition afterwards. If a column was added at the + end then we don't care much since it's not in the middle. */ error= FALSE; + } } //definitely something has changed char buffer[255]; - for (i=0 ;i < table_f_count; ++i, ++table_def) + for (i=0 ; i < table_f_count; i++, table_def++) { - Field *field= table->field[i]; String sql_type(buffer, sizeof(buffer), system_charset_info); sql_type.length(0); /* name changes are not fatal, we use sequence numbers => no prob for us but this can show tampered table or broken table. */ - if (!fields_diff_count || i < table->s->fields) + if (i < table->s->fields) { + Field *field= table->field[i]; if (strncmp(field->field_name, table_def->name.str, table_def->name.length)) { @@ -2459,7 +2461,7 @@ table_check_intact(TABLE *table, uint table_f_count, else { sql_print_error("(%s) Expected field %s at position %d to have type %s " - " but no field found.", table_def->name.str, + " but no field found.", table->alias, table_def->name.str, i, table_def->type.str); error= TRUE; } diff --git a/sql/time.cc b/sql/time.cc index 3c654de23bb..be1e4f10825 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -692,6 +692,7 @@ void make_truncated_value_warning(THD *thd, const char *str_val, char buff[128]; String str(buff,(uint32) sizeof(buff), system_charset_info); str.copy(str_val, str_length, system_charset_info); + str[str_length]= 0; // Ensure we have end 0 for snprintf switch (time_type) { case MYSQL_TIMESTAMP_DATE: |