changeset 3351:5069af20932a

Web viewer: Check the return value of gdcm::Bitmap::GetBuffer()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 23 Apr 2019 10:28:37 +0200
parents ef18ea68a362
children def55522f357
files Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp	Thu Apr 18 15:52:56 2019 +0200
+++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp	Tue Apr 23 10:28:37 2019 +0200
@@ -371,7 +371,10 @@
     if (decoded.empty())
     {
       decoded.resize(pimpl_->GetImage().GetBufferLength());
-      pimpl_->GetImage().GetBuffer(&decoded[0]);
+      if (!pimpl_->GetImage().GetBuffer(&decoded[0]))
+      {
+        throw std::runtime_error("Image not properly decoded to a memory buffer");
+      }
     }
 
     const void* sourceBuffer = &decoded[0];