diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2020-01-15 16:35:59 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2020-01-15 16:35:59 +0300 |
commit | 23041af720416f00db69e07b15861fc6d61b2b45 (patch) | |
tree | fd8fc7f244d3524f115febbd25f9d641b6af4da0 /sql/sql_select.cc | |
parent | 4635047ca1dbcd8b536da4be9236ffab8d48f2d9 (diff) | |
download | mariadb-git-23041af720416f00db69e07b15861fc6d61b2b45.tar.gz |
MDEV-21341: Fix UBSAN failures, part 8: fix error in compare_fields_by_table_order
Dont assign Item_field variables to point to Item_string objects (even if we
don't make any dangerous calls for them).
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 40941294013..2358615affc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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; |