# HG changeset patch # User Sebastien Jodogne # Date 1740416067 -3600 # Node ID 83deef099c75872ab258fc5ab2fa74efd865cd1a # Parent 4db83cdab1bc3596b04736fad48c530655a88561 fix memory leak diff -r 4db83cdab1bc -r 83deef099c75 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Mon Feb 24 17:19:33 2025 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Mon Feb 24 17:54:27 2025 +0100 @@ -1012,18 +1012,18 @@ CompressionType compression, const DicomInstanceToStore* dicomInstance /* can be NULL if not a DICOM instance */) ORTHANC_OVERRIDE { - OrthancPluginMemoryBuffer customDataBuffer; + MemoryBufferRaii customDataBuffer; OrthancPluginErrorCode error; if (dicomInstance != NULL) { Orthanc::OrthancPlugins::DicomInstanceFromCallback wrapped(*dicomInstance); - error = create_(&customDataBuffer, uuid.c_str(), content, size, Plugins::Convert(type), Plugins::Convert(compression), + error = create_(customDataBuffer.GetObject(), uuid.c_str(), content, size, Plugins::Convert(type), Plugins::Convert(compression), reinterpret_cast(&wrapped)); } else { - error = create_(&customDataBuffer, uuid.c_str(), content, size, Plugins::Convert(type), Plugins::Convert(compression), NULL); + error = create_(customDataBuffer.GetObject(), uuid.c_str(), content, size, Plugins::Convert(type), Plugins::Convert(compression), NULL); } if (error != OrthancPluginErrorCode_Success) @@ -1031,11 +1031,9 @@ errorDictionary_.LogError(error, true); throw OrthancException(static_cast(error)); } - - if (customDataBuffer.size > 0) - { - customData.assign(reinterpret_cast(customDataBuffer.data), - static_cast(customDataBuffer.size)); + else + { + customDataBuffer.ToString(customData); } }