# HG changeset patch # User Sebastien Jodogne # Date 1693385250 -7200 # Node ID a862d554753f5c6c39ffe592ff521c2102adabfe # Parent 9ffe8881f8566df0b8a81cc3ef562ea236828664 fixing leaks associated with setting integers diff -r 9ffe8881f856 -r a862d554753f Sources/DicomScpCallbacks.cpp --- a/Sources/DicomScpCallbacks.cpp Wed Aug 30 10:32:26 2023 +0200 +++ b/Sources/DicomScpCallbacks.cpp Wed Aug 30 10:47:30 2023 +0200 @@ -338,7 +338,10 @@ PyDict_SetItemString(kw.GetPyObject(), "TargetAET", tmp.GetPyObject()); } - PyDict_SetItemString(kw.GetPyObject(), "OriginatorID", PyLong_FromUnsignedLong(originatorId_)); + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(originatorId_)); + PyDict_SetItemString(kw.GetPyObject(), "OriginatorID", tmp.GetPyObject()); + } PythonObject args(lock, PyTuple_New(0)); diff -r 9ffe8881f856 -r a862d554753f Sources/IncomingHttpRequestFilter.cpp --- a/Sources/IncomingHttpRequestFilter.cpp Wed Aug 30 10:32:26 2023 +0200 +++ b/Sources/IncomingHttpRequestFilter.cpp Wed Aug 30 10:47:30 2023 +0200 @@ -51,7 +51,11 @@ } PythonObject kw(lock, PyDict_New()); - PyDict_SetItemString(kw.GetPyObject(), "method", PyLong_FromLong(method)); + + { + PythonObject tmp(lock, PyLong_FromLong(method)); + PyDict_SetItemString(kw.GetPyObject(), "method", tmp.GetPyObject()); + } { PythonString str(lock, ip); diff -r 9ffe8881f856 -r a862d554753f Sources/Plugin.cpp --- a/Sources/Plugin.cpp Wed Aug 30 10:32:26 2023 +0200 +++ b/Sources/Plugin.cpp Wed Aug 30 10:47:30 2023 +0200 @@ -81,11 +81,31 @@ PythonLock lock; PythonObject kw(lock, PyDict_New()); - PyDict_SetItemString(kw.GetPyObject(), "Group", PyLong_FromUnsignedLong(entry.group)); - PyDict_SetItemString(kw.GetPyObject(), "Element", PyLong_FromUnsignedLong(entry.element)); - PyDict_SetItemString(kw.GetPyObject(), "ValueRepresentation", PyLong_FromUnsignedLong(entry.vr)); - PyDict_SetItemString(kw.GetPyObject(), "MinMultiplicity", PyLong_FromUnsignedLong(entry.minMultiplicity)); - PyDict_SetItemString(kw.GetPyObject(), "MaxMultiplicity", PyLong_FromUnsignedLong(entry.maxMultiplicity)); + + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.group)); + PyDict_SetItemString(kw.GetPyObject(), "Group", tmp.GetPyObject()); + } + + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.element)); + PyDict_SetItemString(kw.GetPyObject(), "Element", tmp.GetPyObject()); + } + + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.vr)); + PyDict_SetItemString(kw.GetPyObject(), "ValueRepresentation", tmp.GetPyObject()); + } + + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.minMultiplicity)); + PyDict_SetItemString(kw.GetPyObject(), "MinMultiplicity", tmp.GetPyObject()); + } + + { + PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.maxMultiplicity)); + PyDict_SetItemString(kw.GetPyObject(), "MaxMultiplicity", tmp.GetPyObject()); + } return kw.Release(); }