Skip to content

Commit d41c02b

Browse files
author
Guilhem Bichot
committed
Fix for BUG#13489996 valgrind:conditional jump or move depends on uninitialised values-field_blob.
blob_ptr_size was not initialized properly: remove this variable.
1 parent aa253de commit d41c02b

File tree

12 files changed

+26
-20
lines changed

12 files changed

+26
-20
lines changed

mysql-test/r/sp-bugs.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,12 @@ DROP TABLE db1.t1;
110110
DROP DATABASE db1;
111111
DROP DATABASE db2;
112112
End of 5.1 tests
113+
#
114+
# BUG#13489996 valgrind:conditional jump or move depends on
115+
# uninitialised values-field_blob
116+
#
117+
CREATE FUNCTION sf() RETURNS BLOB RETURN "";
118+
SELECT sf();
119+
sf()
120+
121+
DROP FUNCTION sf;

mysql-test/t/sp-bugs.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,12 @@ DROP TABLE db1.t1;
139139
DROP DATABASE db1;
140140
DROP DATABASE db2;
141141
--echo End of 5.1 tests
142+
143+
--echo #
144+
--echo # BUG#13489996 valgrind:conditional jump or move depends on
145+
--echo # uninitialised values-field_blob
146+
--echo #
147+
148+
CREATE FUNCTION sf() RETURNS BLOB RETURN "";
149+
SELECT sf();
150+
DROP FUNCTION sf;

sql/field.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
17561756
if (flags & BLOB_FLAG)
17571757
{
17581758
copy->type= CACHE_BLOB;
1759-
copy->length-= table->s->blob_ptr_size;
1759+
copy->length-= portable_sizeof_char_ptr;
17601760
return copy->length;
17611761
}
17621762
else if (!zero_pack() &&
@@ -10165,11 +10165,6 @@ Create_field::Create_field(Field *old_field,Field *orig_field)
1016510165
comment= old_field->comment;
1016610166
decimals= old_field->decimals();
1016710167

10168-
/* Fix if the original table had 4 byte pointer blobs */
10169-
if (flags & BLOB_FLAG)
10170-
pack_length= (pack_length- old_field->table->s->blob_ptr_size +
10171-
portable_sizeof_char_ptr);
10172-
1017310168
switch (sql_type) {
1017410169
case MYSQL_TYPE_BLOB:
1017510170
switch (pack_length - portable_sizeof_char_ptr) {

sql/field.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,6 +2905,7 @@ class Field_blob :public Field_longstr {
29052905
Field_blob(uint32 packlength_arg)
29062906
:Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
29072907
packlength(packlength_arg) {}
2908+
/* Note that the default copy constructor is used, in clone() */
29082909
enum_field_types type() const { return MYSQL_TYPE_BLOB;}
29092910
bool match_collation_to_optimize_range() const { return true; }
29102911
enum ha_base_keytype key_type() const
@@ -2926,7 +2927,7 @@ class Field_blob :public Field_longstr {
29262927
uint32 key_length() const { return 0; }
29272928
void sort_string(uchar *buff,uint length);
29282929
uint32 pack_length() const
2929-
{ return (uint32) (packlength+table->s->blob_ptr_size); }
2930+
{ return (uint32) (packlength + portable_sizeof_char_ptr); }
29302931

29312932
/**
29322933
Return the packed length without the pointer size added.

sql/field_conv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,8 @@ Copy_field::get_copy_func(Field *to,Field *from)
645645
if (from_length != to_length || !compatible_db_low_byte_first)
646646
{
647647
// Correct pointer to point at char pointer
648-
to_ptr+= to_length - to->table->s->blob_ptr_size;
649-
from_ptr+= from_length- from->table->s->blob_ptr_size;
648+
to_ptr+= to_length - portable_sizeof_char_ptr;
649+
from_ptr+= from_length - portable_sizeof_char_ptr;
650650
return do_copy_blob;
651651
}
652652
}

sql/sql_const.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373

7474
/* Some portable defines */
7575

76-
#define portable_sizeof_char_ptr 8
7776
#define STRING_BUFFER_USUAL_SIZE 80
7877

7978
/* Memory allocated when parsing a statement / saving a statement */

sql/sql_insert.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3742,7 +3742,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
37423742
init_tmp_table_share(thd, &share, "", 0, "", "");
37433743

37443744
tmp_table.s->db_create_options=0;
3745-
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
37463745
tmp_table.s->db_low_byte_first=
37473746
test(create_info->db_type == myisam_hton ||
37483747
create_info->db_type == heap_hton);

sql/sql_tmp_table.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
611611
table->s= share;
612612
init_tmp_table_share(thd, share, "", 0, tmpname, tmpname);
613613
share->blob_field= blob_field;
614-
share->blob_ptr_size= portable_sizeof_char_ptr;
615614
share->db_low_byte_first=1; // True for HEAP and MyISAM
616615
share->table_charset= param->table_charset;
617616
share->primary_key= MAX_KEY; // Indicate no primary key
@@ -1273,7 +1272,6 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
12731272
table->s= share;
12741273
init_tmp_table_share(thd, share, "", 0, tmpname, tmpname);
12751274
share->blob_field= blob_field;
1276-
share->blob_ptr_size= portable_sizeof_char_ptr;
12771275
share->db_low_byte_first=1; // True for HEAP and MyISAM
12781276
share->table_charset= NULL;
12791277
share->primary_key= MAX_KEY; // Indicate no primary key
@@ -1493,7 +1491,6 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list)
14931491
table->temp_pool_slot= MY_BIT_NONE;
14941492
share->blob_field= blob_field;
14951493
share->fields= field_count;
1496-
share->blob_ptr_size= portable_sizeof_char_ptr;
14971494
share->db_low_byte_first=1; // True for HEAP and MyISAM
14981495
setup_tmp_table_column_bitmaps(table, bitmaps);
14991496

@@ -1690,7 +1687,8 @@ bool create_myisam_tmp_table(TABLE *table, KEY *keyinfo,
16901687
seg->type=
16911688
((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ?
16921689
HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2);
1693-
seg->bit_start= (uint8)(field->pack_length() - share->blob_ptr_size);
1690+
seg->bit_start= (uint8)(field->pack_length() -
1691+
portable_sizeof_char_ptr);
16941692
seg->flag= HA_BLOB_PART;
16951693
seg->length=0; // Whole blob in unique constraint
16961694
}

sql/table.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
930930
share->table_charset= default_charset_info;
931931
}
932932
share->db_record_offset= 1;
933-
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
934-
share->blob_ptr_size= portable_sizeof_char_ptr;
935933
/* Set temporarily a good value for db_low_byte_first */
936934
share->db_low_byte_first= test(legacy_db_type != DB_TYPE_ISAM);
937935
error=4;

sql/table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ struct TABLE_SHARE
690690
enum tmp_table_type tmp_table;
691691

692692
uint ref_count; /* How many TABLE objects uses this */
693-
uint blob_ptr_size; /* 4 or 8 */
694693
uint key_block_size; /* create key_block_size, if used */
695694
uint null_bytes, last_null_bit_pos;
696695
uint fields; /* Number of fields */

0 commit comments

Comments
 (0)