From f3b6d56fb2eb8ff2b0c98336339ceeffdfc6c26e Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Sat, 29 Sep 2007 16:04:31 -0300 Subject: [PATCH] The fix for BUG 21136 (ChangeSet@1.2611.1.1) introduced a regression that caused a few tests to fail because the thd->extra_lock wasn't being set to NULL after the table was unlocked. This poses a serious problem because later attempts to access thd->extra_lock (now a dangling pointer) will probably result in a crash (undefined behavior) -- and that's what actually happens in some test cases. The solution is to set the select_create::m_plock pointee to NULL, which means that thd->extra_lock is set to NULL when the lock data is not for a temporary table. --- sql/sql_insert.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fedda29c249..b4f2d8c65f2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3653,7 +3653,8 @@ bool select_create::send_eof() if (m_plock) { mysql_unlock_tables(thd, *m_plock); - m_plock= 0; + *m_plock= NULL; + m_plock= NULL; } } return tmp; @@ -3691,7 +3692,8 @@ void select_create::abort() if (m_plock) { mysql_unlock_tables(thd, *m_plock); - m_plock= 0; + *m_plock= NULL; + m_plock= NULL; } if (table)