Commit 6f36639
committed
MDEV-35815: use-after-poison_in_get_hash_symbol
When a PREPARED statment is executed twice, it is crashing during the
second execution.
For the following query: -
PREPARE stmt FROM 'SELECT tbl.x509_subject AS fld FROM mysql.user AS tbl
GROUP BY fld HAVING 0 AND fld != 1';
During the first execution:
The Item "fld" in the HAVING clause, is an Item_ref instance with name
"fld", where it has a ref to another Item_ref instance with the same name "fld"
which in turn has a reference to another Item with name "x509_subjext".
In the join prepare stage, while in the call to setup_copy_fields() from
make_aggr_tables_info(), the name field of the last Item instance
is replaced with the name in second Item_ref instance. However, after
the first execution is done, the meory for the second Item_ref is freed.
Now, during the second execution of the same statement, when trying to
access name field Item_ref instance, it was getting crashed, because,
that memory was already freed earlier.
The fix is to allocate a new memory in the stmt_arena for the second
Item_ref instance's name->str field.1 parent 21395bb commit 6f36639
3 files changed
+31
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28086 | 28086 | | |
28087 | 28087 | | |
28088 | 28088 | | |
| 28089 | + | |
| 28090 | + | |
| 28091 | + | |
| 28092 | + | |
28089 | 28093 | | |
28090 | 28094 | | |
28091 | 28095 | | |
| |||
0 commit comments