Skip to content

Commit

Permalink
MDEV-21341: Fix UBSAN failures, part 8: fix error in compare_fields_b…
Browse files Browse the repository at this point in the history
…y_table_order

Dont assign Item_field variables to point to Item_string objects (even if we
don't make any dangerous calls for them).
  • Loading branch information
spetrunia committed Jan 15, 2020
1 parent 4635047 commit 23041af
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13669,12 +13669,16 @@ static int compare_fields_by_table_order(Item *field1,
{
int cmp= 0;
bool outer_ref= 0;
Item_field *f1= (Item_field *) (field1->real_item());
Item_field *f2= (Item_field *) (field2->real_item());
if (field1->const_item() || f1->const_item())
Item *field1_real= field1->real_item();
Item *field2_real= field2->real_item();

if (field1->const_item() || field1_real->const_item())
return 1;
if (field2->const_item() || f2->const_item())
if (field2->const_item() || field2_real->const_item())
return -1;

Item_field *f1= (Item_field *) field1_real;
Item_field *f2= (Item_field *) field2_real;
if (f2->used_tables() & OUTER_REF_TABLE_BIT)
{
outer_ref= 1;
Expand Down

0 comments on commit 23041af

Please sign in to comment.