[Commits] 8681b0e191d: MDEV-21341: Fix UBSAN failures, part 8: fix error in compare_fields_by_table_order
revision-id: 8681b0e191ded6e2061cd2b65b18d8d6d9a85491 (mariadb-10.1.43-38-g8681b0e191d) parent(s): 6b24843647540d40d6115dd6b0e2a5a746ea03ca author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-12-18 21:53:19 +0300 message: 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). --- sql/sql_select.cc | 12 ++++++++---- 1 file 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;
participants (1)
-
psergey