[PATCH] Fixed memory leak in single process mode.
authorMarco Eichelberg <dicom@offis.de>
Thu, 9 Jun 2022 08:03:38 +0000 (10:03 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Wed, 19 Jun 2024 20:44:47 +0000 (20:44 +0000)
Fixed a memory leak in dcmqrscp's single process mode.

Thanks to <songxiangpu@mail.sdu.edu.cn> for the bug report and test data.

Gbp-Pq: Name c34f4e46e672ad21accf04da0dc085e43be6f5e1.patch

dcmqrdb/libsrc/dcmqrsrv.cc

index 157e6c0224105234358a483d85e47ee6ae0b6285..f5f9df6617a1ab0bacbac95d1d4b33d319533ce2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- *  Copyright (C) 1993-2021, OFFIS e.V.
+ *  Copyright (C) 1993-2022, OFFIS e.V.
  *  All rights reserved.  See COPYRIGHT file for details.
  *
  *  This software and supporting documentation were developed by
@@ -1126,21 +1126,17 @@ OFCondition DcmQueryRetrieveSCP::waitForAssociation(T_ASC_Network * theNet)
 #endif
     }
 
-    // cleanup code
+    // clean-up association
     OFCondition oldcond = cond;    /* store condition flag for later use */
-    if (!options_.singleProcess_ && (cond != ASC_SHUTDOWNAPPLICATION))
+    cond = ASC_dropAssociation(assoc);
+    if (cond.bad())
     {
-        /* the child will handle the association, we can drop it */
-        cond = ASC_dropAssociation(assoc);
-        if (cond.bad())
-        {
-            DCMQRDB_ERROR("Cannot Drop Association: " << DimseCondition::dump(temp_str, cond));
-        }
-        cond = ASC_destroyAssociation(&assoc);
-        if (cond.bad())
-        {
-            DCMQRDB_ERROR("Cannot Destroy Association: " << DimseCondition::dump(temp_str, cond));
-        }
+        DCMQRDB_ERROR("Cannot Drop Association: " << DimseCondition::dump(temp_str, cond));
+    }
+    cond = ASC_destroyAssociation(&assoc);
+    if (cond.bad())
+    {
+        DCMQRDB_ERROR("Cannot Destroy Association: " << DimseCondition::dump(temp_str, cond));
     }
 
     if (oldcond == ASC_SHUTDOWNAPPLICATION) cond = oldcond; /* abort flag is reported to top-level wait loop */