From 69690fd44e2227a4580e2c0bf1a71971d84a5128 Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Wed, 15 Jan 2025 16:53:09 +0300 Subject: [PATCH] Fix a crash appeared after the bugfix for #8185 (SIGSEGV with WHERE CURRENT OF statement with statement cache turned on). Reproducible with QA test bugs.core_5231 (release build only). This fix is a very simple one, just to avoid the object state being read after its possible removal. The returned usage counter is not used anyway. --- src/dsql/DsqlStatements.cpp | 8 ++------ src/dsql/DsqlStatements.h | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/dsql/DsqlStatements.cpp b/src/dsql/DsqlStatements.cpp index 47117b26a6..c72f38fd95 100644 --- a/src/dsql/DsqlStatements.cpp +++ b/src/dsql/DsqlStatements.cpp @@ -56,17 +56,15 @@ void DsqlStatement::rethrowDdlException(status_exception& ex, bool metadataUpdat status_exception::raise(newVector); } -int DsqlStatement::release() +void DsqlStatement::release() { fb_assert(refCounter.value() > 0); - int refCnt = --refCounter; - if (!refCnt) + if (!--refCounter) { if (cacheKey) { dsqlAttachment->dbb_statement_cache->statementGoingInactive(cacheKey); - refCnt = refCounter; } else { @@ -74,8 +72,6 @@ int DsqlStatement::release() dsqlAttachment->deletePool(&getPool()); } } - - return refCnt; } void DsqlStatement::doRelease() diff --git a/src/dsql/DsqlStatements.h b/src/dsql/DsqlStatements.h index 1ab48fc986..399852bf63 100644 --- a/src/dsql/DsqlStatements.h +++ b/src/dsql/DsqlStatements.h @@ -83,12 +83,12 @@ protected: virtual ~DsqlStatement() = default; public: - int addRef() + void addRef() { - return ++refCounter; + ++refCounter; } - int release(); + void release(); bool isCursorBased() const {