changeset 6739:ace9135428dd

fix a memory leak in C-Get
author Alain Mazy <am@orthanc.team>
date Wed, 06 May 2026 14:38:37 +0200
parents bae99026ca97
children 9551353f3e03
files NEWS OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed May 06 12:40:49 2026 +0200
+++ b/NEWS	Wed May 06 14:38:37 2026 +0200
@@ -34,6 +34,7 @@
   was required.
 * Fix usage of "LocalAet" in C-Find and "queries/../answers/../retrieve".
 * Fix Orthanc::ImageAccessor that was broken in Orthanc Framework 1.12.11
+* Fix a memory leak in C-GET (https://github.com/orthanc-server/orthanc-builder/issues/36)
 * Fix a Denial of Service via Deeply Nested DICOM Sequences
   https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=258
   Security issue reported by Jose Lopez Martinez (aka elpe_pinillo) from Deloitte.
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Wed May 06 12:40:49 2026 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Wed May 06 14:38:37 2026 +0200
@@ -689,16 +689,18 @@
           }
 
           Uint16 desiredCStoreReturnStatus = 0;
-          DcmDataset* dataObject = NULL;
+          DcmDataset* dataObjectRawPtr = NULL;
 
           // Receive dataset
           result = DIMSE_receiveDataSetInMemory(&(association_->GetDcmtkAssociation()),
                                                   (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
                                                   parameters_.GetTimeout(),
                                                   &cmdPresId,
-                                                  &dataObject,
+                                                  &dataObjectRawPtr,
                                                   NULL, NULL);
 
+          std::unique_ptr<DcmDataset> dataObject(dataObjectRawPtr); // to handle deallocation correctly
+
           if (result.bad())
           {
             LOG(WARNING) << "C-GET SCU handler: Failed to receive dataset: " << result.text();