diff --new-file -urEb Orthanc-1.5.6.orig/patched Orthanc-1.5.6/patched
--- Orthanc-1.5.6.orig/patched	1970-01-01 01:00:00.000000000 +0100
+++ Orthanc-1.5.6/patched	2019-03-04 16:41:37.532734849 +0100
@@ -0,0 +1 @@
+patched
diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	2019-03-04 16:19:10.126165813 +0100
+++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	2019-03-04 16:19:39.330128951 +0100
@@ -145,6 +145,13 @@
   }
 
 
+  void MemoryBuffer::Swap(MemoryBuffer& other)
+  {
+    std::swap(buffer_.data, other.buffer_.data);
+    std::swap(buffer_.size, other.buffer_.size);
+  }
+
+
   OrthancPluginMemoryBuffer MemoryBuffer::Release()
   {
     OrthancPluginMemoryBuffer result = buffer_;
@@ -1024,11 +1031,11 @@
   {
     CheckImageAvailable();
 
-    OrthancPluginMemoryBuffer tmp;
-    OrthancPluginCompressPngImage(GetGlobalContext(), &tmp, GetPixelFormat(),
+    OrthancPlugins::MemoryBuffer answer;
+    OrthancPluginCompressPngImage(GetGlobalContext(), *answer, GetPixelFormat(),
                                   GetWidth(), GetHeight(), GetPitch(), GetBuffer());
 
-    target.Assign(tmp);
+    target.Swap(answer);
   }
 
 
@@ -1037,11 +1044,11 @@
   {
     CheckImageAvailable();
 
-    OrthancPluginMemoryBuffer tmp;
-    OrthancPluginCompressJpegImage(GetGlobalContext(), &tmp, GetPixelFormat(),
+    OrthancPlugins::MemoryBuffer answer;
+    OrthancPluginCompressJpegImage(GetGlobalContext(), *answer, GetPixelFormat(),
                                    GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality);
 
-    target.Assign(tmp);
+    target.Swap(answer);
   }
 
 
@@ -1580,16 +1587,16 @@
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
     }
 
-    OrthancPluginMemoryBuffer answer;
+    OrthancPlugins::MemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-        (GetGlobalContext(), &answer, NULL, &status, peers_,
+        (GetGlobalContext(), *answer, NULL, &status, peers_,
          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(),
          0, NULL, NULL, NULL, 0, timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
-      target.Assign(answer);
+      target.Swap(answer);
       return (status == 200);
     }
     else
@@ -1704,16 +1711,16 @@
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
     }
 
-    OrthancPluginMemoryBuffer answer;
+    OrthancPlugins::MemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-        (GetGlobalContext(), &answer, NULL, &status, peers_,
+        (GetGlobalContext(), *answer, NULL, &status, peers_,
          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(),
          0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
-      target.Assign(answer);
+      target.Swap(answer);
       return (status == 200);
     }
     else
@@ -1732,16 +1739,15 @@
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
     }
 
-    OrthancPluginMemoryBuffer answer;
+    OrthancPlugins::MemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-        (GetGlobalContext(), &answer, NULL, &status, peers_,
+        (GetGlobalContext(), *answer, NULL, &status, peers_,
          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
          0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
-      OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer);
       return (status == 200);
     }
     else
@@ -1769,16 +1775,15 @@
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
     }
 
-    OrthancPluginMemoryBuffer answer;
+    OrthancPlugins::MemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-        (GetGlobalContext(), &answer, NULL, &status, peers_,
-         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
+      (GetGlobalContext(), *answer, NULL, &status, peers_,
+       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Delete, uri.c_str(),
          0, NULL, NULL, NULL, 0, timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
-      OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer);
       return (status == 200);
     }
     else
diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h
--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h	2019-03-04 16:19:10.126165813 +0100
+++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h	2019-03-04 16:19:42.018125583 +0100
@@ -129,6 +129,8 @@
     // This transfers ownership from "other" to "this"
     void Assign(OrthancPluginMemoryBuffer& other);
 
+    void Swap(MemoryBuffer& other);
+
     OrthancPluginMemoryBuffer Release();
 
     const char* GetData() const
