Skip to content

Commit 5042514

Browse files
committed
Fix Statement destructor since addition of the move constructor
1 parent f2b1017 commit 5042514

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/Statement.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -466,30 +466,32 @@ Statement::Ptr::Ptr(Ptr&& aPtr) :
466466
aPtr.mpStmt = NULL;
467467
aPtr.mpRefCount = NULL;
468468
}
469-
#endif
469+
#endif
470470

471471
/**
472472
* @brief Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0
473473
*/
474474
Statement::Ptr::~Ptr()
475475
{
476-
assert(NULL != mpRefCount);
477-
assert(0 != *mpRefCount);
478-
479-
// Decrement and check the reference counter of the sqlite3_stmt
480-
--(*mpRefCount);
481-
if (0 == *mpRefCount)
476+
if (NULL != mpRefCount)
482477
{
483-
// If count reaches zero, finalize the sqlite3_stmt, as no Statement nor Column objet use it anymore.
484-
// No need to check the return code, as it is the same as the last statement evaluation.
485-
sqlite3_finalize(mpStmt);
486-
487-
// and delete the reference counter
488-
delete mpRefCount;
489-
mpRefCount = NULL;
490-
mpStmt = NULL;
478+
assert(0 != *mpRefCount);
479+
480+
// Decrement and check the reference counter of the sqlite3_stmt
481+
--(*mpRefCount);
482+
if (0 == *mpRefCount)
483+
{
484+
// If count reaches zero, finalize the sqlite3_stmt, as no Statement nor Column objet use it anymore.
485+
// No need to check the return code, as it is the same as the last statement evaluation.
486+
sqlite3_finalize(mpStmt);
487+
488+
// and delete the reference counter
489+
delete mpRefCount;
490+
mpRefCount = NULL;
491+
mpStmt = NULL;
492+
}
493+
// else, the finalization will be done later, by the last object
491494
}
492-
// else, the finalization will be done later, by the last object
493495
}
494496

495497

0 commit comments

Comments
 (0)