Mercurial > hg > orthanc-object-storage
changeset 43:4c71c5e2edce
fix memory handling in legacy read
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 19 Mar 2021 17:37:46 +0100 |
parents | d99afdf6d872 |
children | 2f5fd8a80636 |
files | Common/StoragePlugin.cpp |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/StoragePlugin.cpp Fri Mar 19 10:13:49 2021 +0100 +++ b/Common/StoragePlugin.cpp Fri Mar 19 17:37:46 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;