diff options
author | Georgi Kodinov <joro@sun.com> | 2010-03-23 17:07:00 +0200 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2010-03-23 17:07:00 +0200 |
commit | a9a2ceae1f360c275ed4db5b093ab65be4f5fb7b (patch) | |
tree | 71054058de67ea839694187d4caf855a62f8131e /sql | |
parent | a35418784bc35f5b6c461689c954bdcfbb4c9b33 (diff) | |
download | mariadb-git-a9a2ceae1f360c275ed4db5b093ab65be4f5fb7b.tar.gz |
Bug #51850: crash/memory overlap when using load data infile and set
col equal to itself!
There's no need to copy the value of a field into itself.
While generally harmless (except for some performance penalties)
it may be dangerous when the copy code doesn't expect this.
Fixed by checking if the source field is the same as the destination
field before copying the data.
Note that we must preserve the order of assignment of the null
flags (hence the null_value assignment addition).
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sql/item.cc b/sql/item.cc index d253e19e068..809377e80b3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5063,14 +5063,22 @@ int Item_field::save_in_field(Field *to, bool no_conversions) if (result_field->is_null()) { null_value=1; - res= set_field_to_null_with_conversions(to, no_conversions); + return set_field_to_null_with_conversions(to, no_conversions); } - else + to->set_notnull(); + + /* + If we're setting the same field as the one we're reading from there's + nothing to do. This can happen in 'SET x = x' type of scenarios. + */ + if (to == result_field) { - to->set_notnull(); - res= field_conv(to,result_field); null_value=0; + return 0; } + + res= field_conv(to,result_field); + null_value=0; return res; } |