mirror of
https://github.com/MariaDB/server.git
synced 2026-05-05 06:35:33 +02:00
Bug #57187: more user variable fun with multiple
assignments and comparison in query
A query that compares assignments of the same
user variable caused Valgrind warnings: access
to freed memory region.
In case of a DECIMAL argument the assignment
operator (:=) may return a pointer to a stored
value instead of its copy when evaluated.
The next assignment to the same variable may:
a) overwrite the stored value with a new one
and return the same pointer or even
b) reallocate stored value.
Thus, if we evaluate an assignment and keep
the result pointer and then evaluate another
assignment to the same variable, then the
kept result pointer of the first assignment
will point to unexpectedly changed data or
it may be a dead pointer.
That may cause wrong data or crash.
The user_var_entry::val_decimal method has
been modified to copy user variable data.
This commit is contained in:
parent
7c6fc82816
commit
a44b544498
3 changed files with 19 additions and 1 deletions
|
|
@ -4064,7 +4064,7 @@ my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val)
|
|||
int2my_decimal(E_DEC_FATAL_ERROR, *(longlong*) value, 0, val);
|
||||
break;
|
||||
case DECIMAL_RESULT:
|
||||
val= (my_decimal *)value;
|
||||
my_decimal2decimal((my_decimal *) value, val);
|
||||
break;
|
||||
case STRING_RESULT:
|
||||
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue