changeset 3324:87396c571109

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Mar 2019 12:39:04 +0100
parents a15a4b9d8c00
children f0c92ecd09c8
files Core/Toolbox.cpp
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Tue Mar 19 09:00:34 2019 +0100
+++ b/Core/Toolbox.cpp	Wed Mar 20 12:39:04 2019 +0100
@@ -1818,7 +1818,8 @@
       throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
 
-    const uint8_t* buffer = reinterpret_cast<const uint8_t*>(utf8.c_str());
+    assert(sizeof(uint8_t) == sizeof(char));
+    const uint8_t* buffer = reinterpret_cast<const uint8_t*>(utf8.c_str()) + position;
 
     if ((buffer[0] & MASK_IS_1_BYTE) == TEST_IS_1_BYTE)
     {
@@ -1861,7 +1862,7 @@
     else
     {
       // This is not a valid UTF-8 encoding
-      throw OrthancException(ErrorCode_BadFileFormat);
+      throw OrthancException(ErrorCode_BadFileFormat, "Invalid UTF-8 string");
     }
   }
 }