Mercurial > hg > orthanc-python
changeset 127:a862d554753f fix-leak
fixing leaks associated with setting integers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Aug 2023 10:47:30 +0200 |
parents | 9ffe8881f856 |
children | 5b59ebc267e1 |
files | Sources/DicomScpCallbacks.cpp Sources/IncomingHttpRequestFilter.cpp Sources/Plugin.cpp |
diffstat | 3 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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));
--- 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);
--- 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(); }