Mercurial > hg > orthanc-databases
comparison Framework/Common/DatabaseManager.cpp @ 526:4dc0ea12d537
fix memory leak
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Jul 2024 14:00:08 +0200 |
parents | 54d518dcd74a |
children | 25cfcb752af6 |
comparison
equal
deleted
inserted
replaced
519:586b80ea397c | 526:4dc0ea12d537 |
---|---|
661 // is not destroyed, as the "IResult" can make calls to the | 661 // is not destroyed, as the "IResult" can make calls to the |
662 // statement (this is the case for SQLite and MySQL) - (*) | 662 // statement (this is the case for SQLite and MySQL) - (*) |
663 statement_.reset(GetManager().GetDatabase().Compile(*query)); | 663 statement_.reset(GetManager().GetDatabase().Compile(*query)); |
664 assert(statement_.get() != NULL); | 664 assert(statement_.get() != NULL); |
665 | 665 |
666 std::unique_ptr<IResult> result(GetTransaction().Execute(*statement_, parameters)); | |
667 | |
666 if (withResults) | 668 if (withResults) |
667 { | 669 { |
668 SetResult(GetTransaction().Execute(*statement_, parameters)); | 670 SetResult(result.release()); |
669 } | |
670 else | |
671 { | |
672 GetTransaction().Execute(*statement_, parameters); | |
673 } | 671 } |
674 } | 672 } |
675 catch (Orthanc::OrthancException& e) | 673 catch (Orthanc::OrthancException& e) |
676 { | 674 { |
677 GetManager().CloseIfUnavailable(e.GetErrorCode()); | 675 GetManager().CloseIfUnavailable(e.GetErrorCode()); |