# HG changeset patch # User Alain Mazy # Date 1616171876 -3600 # Node ID 2f5fd8a80636e4b092207a47a74a5c1c838281e5 # Parent 4c71c5e2edce89bb4ba520888d3ccde90639e9ad# Parent 822e29256ffb944b74a6f659568cfae08bcebae6 merge diff -r 822e29256ffb -r 2f5fd8a80636 Common/StoragePlugin.cpp --- a/Common/StoragePlugin.cpp Fri Mar 19 12:13:18 2021 +0100 +++ b/Common/StoragePlugin.cpp Fri Mar 19 17:37:56 2021 +0100 @@ -226,14 +226,13 @@ const char* uuid, OrthancPluginContentType type) { - OrthancPluginMemoryBuffer64* buffer = nullptr; - OrthancPluginErrorCode result = StorageReadWhole(buffer, uuid, type); // allocates the buffer but Orthanc won't delete it -> to delete ourselves + OrthancPluginMemoryBuffer64 buffer; + OrthancPluginErrorCode result = StorageReadWhole(&buffer, uuid, type); // will allocate OrthancPluginMemoryBuffer64 - if (buffer != nullptr) + if (result == OrthancPluginErrorCode_Success) { - *size = buffer->size; - memcpy(*content, buffer->data, buffer->size); - OrthancPluginFreeMemoryBuffer64(OrthancPlugins::GetGlobalContext(), buffer); + *size = buffer.size; + *content = buffer.data; // orthanc will free the buffer (we don't have to delete it ourselves) } return result;