changeset 4973:17c91e054636

minor improvements
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Apr 2022 12:04:48 +0200
parents cde17b68d73e
children fcdf399f9fc0
files OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Apr 04 09:52:54 2022 +0200
+++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Apr 07 12:04:48 2022 +0200
@@ -3703,7 +3703,13 @@
 
     try
     {
-      *isReadOnly = (that.StoreFile(WebDavConvertPath(pathSize, pathItems), data, size) ? 1 : 0);
+      if (static_cast<uint64_t>(static_cast<size_t>(size)) != size)
+      {
+        ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory);
+      }
+      
+      *isReadOnly = (that.StoreFile(WebDavConvertPath(pathSize, pathItems), data,
+                                    static_cast<size_t>(size)) ? 1 : 0);
       return OrthancPluginErrorCode_Success;
     }
     catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
--- a/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py	Mon Apr 04 09:52:54 2022 +0200
+++ b/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py	Thu Apr 07 12:04:48 2022 +0200
@@ -116,7 +116,8 @@
     info = r.json()
     COUNT_DICOM += 1
 
-    if not info['ParentStudy'] in IMPORTED_STUDIES:
+    if (isinstance(info, dict) and
+        not info['ParentStudy'] in IMPORTED_STUDIES):
         IMPORTED_STUDIES.add(info['ParentStudy'])
         
         r2 = requests.get('%s/instances/%s/tags?short' % (args.url, info['ID']),