[Commits] Rev 3593: MDEV-3810 fix. in file:///home/tsk/mprog/src/5.3-merge/

timour at askmonty.org timour at askmonty.org
Thu Nov 8 15:58:10 EET 2012


At file:///home/tsk/mprog/src/5.3-merge/

------------------------------------------------------------
revno: 3593
revision-id: timour at askmonty.org-20121108135754-jnv4rrqyftwvtr0l
parent: timour at askmonty.org-20121108132936-ge1ztfuzmoln0syh
fixes bug(s): https://mariadb.atlassian.net/browse/MDEV-3810
committer: timour at askmonty.org
branch nick: 5.3-merge
timestamp: Thu 2012-11-08 15:57:54 +0200
message:
  MDEV-3810 fix.
  
  The problem is that memory aloocated by copy_andor_structure() well be freed,
  but if level of SELECT_LEX it will be excluded (in case of merge derived tables and view)
  then sl->where/having will not be updated here but still can be accessed (so it will be access to freed memory).
  
  (Patch by Sanja)
-------------- next part --------------
=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2012-11-08 13:29:36 +0000
+++ b/sql/sql_prepare.cc	2012-11-08 13:57:54 +0000
@@ -2447,14 +2447,24 @@ void reinit_stmt_before_use(THD *thd, LE
       */
       if (sl->prep_where)
       {
-        sl->where= sl->prep_where->copy_andor_structure(thd);
+        /*
+          We need this rollback because memory allocated in
+          copy_andor_structure() will be freed
+        */
+        thd->change_item_tree((Item**)&sl->where,
+                              sl->prep_where->copy_andor_structure(thd));
         sl->where->cleanup();
       }
       else
         sl->where= NULL;
       if (sl->prep_having)
       {
-        sl->having= sl->prep_having->copy_andor_structure(thd);
+        /*
+          We need this rollback because memory allocated in
+          copy_andor_structure() will be freed
+        */
+        thd->change_item_tree((Item**)&sl->having,
+                              sl->prep_having->copy_andor_structure(thd));
         sl->having->cleanup();
       }
       else



More information about the commits mailing list