diff --git a/src/jrd/execute_statement.cpp b/src/jrd/execute_statement.cpp index 79f8e91628..5c81c5cc9c 100644 --- a/src/jrd/execute_statement.cpp +++ b/src/jrd/execute_statement.cpp @@ -89,7 +89,8 @@ void startCallback(thread_db* tdbb) #if (defined DEV_BUILD && !defined MULTI_THREAD) tdbb->getDatabase()->dbb_flags |= DBB_exec_statement; #endif - tdbb->getTransaction()->tra_callback_count++; + if (tdbb->getTransaction()) + tdbb->getTransaction()->tra_callback_count++; THREAD_EXIT(); } @@ -99,7 +100,8 @@ void finishCallback(thread_db* tdbb) #if (defined DEV_BUILD && !defined MULTI_THREAD) tdbb->getDatabase()->dbb_flags &= ~DBB_exec_statement; #endif - tdbb->getTransaction()->tra_callback_count--; + if (tdbb->getTransaction()) + tdbb->getTransaction()->tra_callback_count--; } } // anonymous namespace @@ -294,15 +296,21 @@ void ExecuteStatement::Close(thread_db* tdbb) Statement = 0; } - char* p = reinterpret_cast(Sqlda); - delete[] p; + + // if transaction is already missing, it's pool is also deleted, + // i.e. impossible and no use deleting something from it + if (tdbb->getTransaction()) { + char* p = reinterpret_cast(Sqlda); + delete[] p; + delete[] Buffer; + } Sqlda = 0; + Buffer = 0; + if (Transaction) { delete YValve::translate(&Transaction); Transaction = 0; } - delete[] Buffer; - Buffer = 0; } XSQLDA* ExecuteStatement::MakeSqlda(thread_db* tdbb, short n)