diff --git a/ThirdParty/expat/vtkexpat/CMakeLists.txt b/ThirdParty/expat/vtkexpat/CMakeLists.txt
index d9fc52849fbcb198d737b962b5a247d0206b38bf..3a65e721f9e41d9d3a967152f762797e253cc302 100644
--- a/ThirdParty/expat/vtkexpat/CMakeLists.txt
+++ b/ThirdParty/expat/vtkexpat/CMakeLists.txt
@@ -4,13 +4,15 @@
 if (FALSE) # XXX(kitware): Force build settings.
 project(expat)
 
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8.10)
 set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org")
 set(PACKAGE_NAME "expat")
-set(PACKAGE_VERSION "2.2.5")
+set(PACKAGE_VERSION "2.2.6")
 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
 set(PACKAGE_TARNAME "${PACKAGE_NAME}")
 
+include(GNUInstallDirs)
+
 if(WINCE)
     set(BUILD_tools_default OFF)
 else()
@@ -19,7 +21,7 @@ endif()
 if(MSVC OR NOT BUILD_tools_default)
     set(BUILD_doc_default OFF)
 else()
-    find_program(DOCBOOK_TO_MAN NAMES docbook2x-man docbook2man docbook-to-man)
+    find_program(DOCBOOK_TO_MAN NAMES docbook2x-man db2x_docbook2man docbook2man docbook-to-man)
     if(DOCBOOK_TO_MAN)
         set(BUILD_doc_default ON)
     else()
@@ -58,10 +60,12 @@ if (FALSE) # XXX(kitware): Force configuration values.
 set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")
 option(XML_DTD "Define to make parameter entity parsing functionality available" ON)
 option(XML_NS "Define to make XML Namespaces functionality available" ON)
+option(WARNINGS_AS_ERRORS "Treat all compiler warnings as errors" OFF)
 else ()
 set(XML_CONTEXT_BYTES 1024)
 set(XML_DTD ON)
 set(XML_NS ON)
+set(WARNINGS_AS_ERRORS OFF)
 endif ()
 if(NOT WIN32)
     if (FALSE) # XXX(kitware): Force configuration values.
@@ -70,9 +74,18 @@ if(NOT WIN32)
     set(XML_DEV_URANDOM ON)
     endif ()
     if(XML_DEV_URANDOM)
-        add_definitions(-DXML_DEV_URANDOM)
-    endif()
+        set(XML_DEV_URANDOM 1)
+    else(XML_DEV_URANDOM)
+        set(XML_DEV_URANDOM 0)
+    endif(XML_DEV_URANDOM)
 endif()
+if (FALSE) # XXX(kitware): Force configuration values.
+option(XML_UNICODE "Use UTF-16 encoded chars (two bytes) instead of UTF-8" OFF)
+option(XML_UNICODE_WCHAR_T "Use wchar_t to represent UTF-16 instead of unsigned short" OFF)
+else ()
+set(XML_UNICODE OFF)
+set(XML_UNICODE_WCHAR_T OFF)
+endif ()
 
 if(XML_DTD)
     set(XML_DTD 1)
@@ -84,6 +97,25 @@ if(XML_NS)
 else(XML_NS)
     set(XML_NS 0)
 endif(XML_NS)
+if(XML_UNICODE)
+    set(XML_UNICODE 1)
+else(XML_UNICODE)
+    set(XML_UNICODE 0)
+endif(XML_UNICODE)
+if(XML_UNICODE_WCHAR_T)
+    set(XML_UNICODE_WCHAR_T 1)
+else(XML_UNICODE_WCHAR_T)
+    set(XML_UNICODE_WCHAR_T 0)
+endif(XML_UNICODE_WCHAR_T)
+
+if(XML_UNICODE_WCHAR_T AND NOT XML_UNICODE)
+    message(SEND_ERROR "Option XML_UNICODE_WCHAR_T=ON may not be used without XML_UNICODE=ON.")
+    set(XML_UNICODE 1)
+endif(XML_UNICODE_WCHAR_T AND NOT XML_UNICODE)
+
+if(BUILD_tools AND (XML_UNICODE AND NOT XML_UNICODE_WCHAR_T))
+    message(SEND_ERROR "The xmlwf tool can not be built with option XML_UNICODE_WCHAR_T=OFF and XML_UNICODE=ON. Either set XML_UNICODE_WCHAR_T=ON or BUILD_tools=OFF.")
+endif()
 
 if(BUILD_tests)
     enable_testing()
@@ -96,10 +128,40 @@ set(EXTRA_COMPILE_FLAGS)
 if(FLAG_NO_STRICT_ALIASING)
     set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fno-strict-aliasing")
 endif()
+if (WARNINGS_AS_ERRORS)
+    if(MSVC)
+        add_definitions(/WX)
+    else(MSVC)
+        set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -Werror")
+    endif(MSVC)
+endif(WARNINGS_AS_ERRORS)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")
 endif ()
 
+if (FALSE) # XXX(kitware): Force build settings.
+set(MSVC_USE_STATIC_CRT OFF CACHE BOOL "Use /MT flag (static CRT) when compiling in MSVC")
+else ()
+set(MSVC_USE_STATIC_CRT OFF)
+endif ()
+if (MSVC)
+    if (MSVC_USE_STATIC_CRT)
+        message("-- Using static CRT ${MSVC_USE_STATIC_CRT}")
+        foreach(flag_var
+                CMAKE_CXX_FLAGS_DEBUG
+                CMAKE_CXX_FLAGS_RELEASE
+                CMAKE_CXX_FLAGS_MINSIZEREL
+                CMAKE_CXX_FLAGS_RELWITHDEBINFO
+                CMAKE_C_FLAGS_DEBUG
+                CMAKE_C_FLAGS_RELEASE
+                CMAKE_C_FLAGS_MINSIZEREL
+                CMAKE_C_FLAGS_RELWITHDEBINFO
+                )
+            string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+        endforeach()
+    endif()
+endif()
+
 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
 
 if (FALSE) # XXX(kitware): Settings handled by VTK.
@@ -123,7 +185,7 @@ set(expat_SRCS
 if(BUILD_shared)
     set(_SHARED SHARED)
     if(WIN32)
-        if (FALSE)
+        if (FALSE) # XXX(kitware): Exporting is handled via generate_export_header
         set(expat_SRCS ${expat_SRCS} lib/libexpat.def)
         endif ()
     endif(WIN32)
@@ -141,7 +203,7 @@ if(USE_libbsd)
 endif()
 
 set(LIBCURRENT 7)   # sync
-set(LIBREVISION 7)  # with
+set(LIBREVISION 8)  # with
 set(LIBAGE 6)       # configure.ac!
 math(EXPR LIBCURRENT_MINUS_AGE "${LIBCURRENT} - ${LIBAGE}")
 
@@ -157,9 +219,9 @@ macro(expat_install)
     endif()
 endmacro()
 
-expat_install(TARGETS expat RUNTIME DESTINATION bin
-                      LIBRARY DESTINATION lib
-                      ARCHIVE DESTINATION lib)
+expat_install(TARGETS expat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+                      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+                      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 else ()
 set(expat_headers
     lib/expat.h
@@ -170,14 +232,11 @@ if (NOT BUILD_SHARED_LIBS)
   set(XML_STATIC 1)
 endif ()
 
-vtk_add_library(vtkexpat ${expat_SRCS} ${expat_headers})
-if (NOT VTK_INSTALL_NO_DEVELOPMENT)
-  install(FILES
-    ${expat_headers}
-    DESTINATION "${VTK_INSTALL_INCLUDE_DIR}/vtkexpat/lib"
-    COMPONENT Development)
-endif()
-target_compile_definitions(vtkexpat
+vtk_module_add_module(VTK::expat
+  SOURCES ${expat_SRCS}
+  HEADERS ${expat_headers}
+  HEADERS_SUBDIR "vtkexpat/lib")
+target_compile_definitions(expat
   PRIVATE
     # Support XML files >2GB.
     XML_LARGE_SIZE)
@@ -185,16 +244,15 @@ endif ()
 
 if (FALSE) # XXX(kitware): Do not install a .pc file.
 set(prefix ${CMAKE_INSTALL_PREFIX})
-set(exec_prefix "\${prefix}/bin")
-set(libdir "\${prefix}/lib")
+set(exec_prefix "\${prefix}")
+set(libdir "\${exec_prefix}/lib")
 set(includedir "\${prefix}/include")
-configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc)
+configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc @ONLY)
 
-expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION include)
-expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)
+expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 endif ()
 
-
 if(BUILD_tools)
     set(xmlwf_SRCS
         xmlwf/xmlwf.c
@@ -206,10 +264,10 @@ if(BUILD_tools)
     add_executable(xmlwf ${xmlwf_SRCS})
     set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)
     target_link_libraries(xmlwf expat)
-    expat_install(TARGETS xmlwf DESTINATION bin)
+    expat_install(TARGETS xmlwf DESTINATION ${CMAKE_INSTALL_BINDIR})
     if(BUILD_doc)
         add_custom_command(TARGET expat PRE_BUILD COMMAND "${DOCBOOK_TO_MAN}" "${PROJECT_SOURCE_DIR}/doc/xmlwf.xml" && mv "XMLWF.1" "${PROJECT_SOURCE_DIR}/doc/xmlwf.1")
-        expat_install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION share/man/man1)
+        expat_install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
     endif()
 endif()
 
diff --git a/ThirdParty/expat/vtkexpat/ConfigureChecks.cmake b/ThirdParty/expat/vtkexpat/ConfigureChecks.cmake
index 13f470d39c43d7af2e9db9aae4b02df5031de896..dbb49210202fbc9b5b564ebf728a6e4038b1846d 100644
--- a/ThirdParty/expat/vtkexpat/ConfigureChecks.cmake
+++ b/ThirdParty/expat/vtkexpat/ConfigureChecks.cmake
@@ -18,7 +18,6 @@ check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_file("unistd.h" HAVE_UNISTD_H)
 
 check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)
-check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
 check_symbol_exists("bcopy" "strings.h" HAVE_BCOPY)
 check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE)
 check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)
@@ -26,10 +25,13 @@ check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
 
 if(USE_libbsd)
     set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")
+    set(_bsd "bsd/")
+else()
+    set(_bsd "")
 endif()
-check_symbol_exists("arc4random_buf" "stdlib.h" HAVE_ARC4RANDOM_BUF)
+check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)
 if(NOT HAVE_ARC4RANDOM_BUF)
-    check_symbol_exists("arc4random" "stdlib.h" HAVE_ARC4RANDOM)
+    check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM)
 endif()
 set(CMAKE_REQUIRED_LIBRARIES)
 
diff --git a/ThirdParty/expat/vtkexpat/README.md b/ThirdParty/expat/vtkexpat/README.md
index 984e927e810134e118fad804df01ae781c340c4d..2c7e6ac40506590305b9cdb2ee17de5d7c1ee414 100644
--- a/ThirdParty/expat/vtkexpat/README.md
+++ b/ThirdParty/expat/vtkexpat/README.md
@@ -2,7 +2,7 @@
 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat)
 
 
-# Expat, Release 2.2.5
+# Expat, Release 2.2.6
 
 This is Expat, a C library for parsing XML, started by
 [James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997.
diff --git a/ThirdParty/expat/vtkexpat/expat_config.h.cmake b/ThirdParty/expat/vtkexpat/expat_config.h.cmake
index 34e43958663ad6483ce5e67b2d28787133656a93..0b630c97446d03be39a845b476c54f6147d01099 100644
--- a/ThirdParty/expat/vtkexpat/expat_config.h.cmake
+++ b/ThirdParty/expat/vtkexpat/expat_config.h.cmake
@@ -33,15 +33,6 @@
 /* Define to 1 if you have the `memmove' function. */
 #cmakedefine HAVE_MEMMOVE
 
-/* Define to 1 if you have the `getrandom' function. */
-#cmakedefine HAVE_GETRANDOM
-
-/* Define to 1 if you have the `SYS_getrandom' function. */
-#cmakedefine HAVE_SYSCALL_GETRANDOM
-
-/* Define to 1 if you have the `arc4random_buf' function. */
-#cmakedefine HAVE_ARC4RANDOM_BUF
-
 /* XXX(kitware): VTK is fine with low entropy. */
 #define XML_POOR_ENTROPY
 
@@ -106,6 +97,17 @@
 /* Define to make XML Namespaces functionality available. */
 #cmakedefine XML_NS
 
+#if ! defined(_WIN32)
+/* Define to extract entropy from /dev/urandom. */
+#cmakedefine XML_DEV_URANDOM
+#endif
+
+/* Define to use UTF-16 chars (two bytes). */
+#cmakedefine XML_UNICODE
+
+/* Define to use wchar_t as UTF-16 char type instead of unsigned short. */
+#cmakedefine XML_UNICODE_WCHAR_T
+
 /* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */
 #ifdef _MSC_VER
 # define __func__ __FUNCTION__
diff --git a/ThirdParty/expat/vtkexpat/lib/expat.h b/ThirdParty/expat/vtkexpat/lib/expat.h
index 2b0f58b19f20c82aa286bf7949ecbf52eb331152..0a1649d8d9ae5d3da6538089414ffebb1af53c9e 100644
--- a/ThirdParty/expat/vtkexpat/lib/expat.h
+++ b/ThirdParty/expat/vtkexpat/lib/expat.h
@@ -266,7 +266,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
                     const XML_Char *namespaceSeparator);
 
 /* Prepare a parser object to be re-used.  This is particularly
-   valuable when memory allocation overhead is disproportionatly high,
+   valuable when memory allocation overhead is disproportionately high,
    such as when a large number of small documnents need to be parsed.
    All handlers are cleared from the parser, except for the
    unknownEncodingHandler. The parser's external state is re-initialized
@@ -1078,7 +1078,7 @@ XML_GetFeatureList(void);
 */
 #define XML_MAJOR_VERSION 2
 #define XML_MINOR_VERSION 2
-#define XML_MICRO_VERSION 5
+#define XML_MICRO_VERSION 6
 
 #ifdef __cplusplus
 }
diff --git a/ThirdParty/expat/vtkexpat/lib/siphash.h b/ThirdParty/expat/vtkexpat/lib/siphash.h
index 581872df7b499247f46ec3c910bb8a929d71caca..4d6786d7839a2c1a99989930afec3dbe8789a2bc 100644
--- a/ThirdParty/expat/vtkexpat/lib/siphash.h
+++ b/ThirdParty/expat/vtkexpat/lib/siphash.h
@@ -11,6 +11,12 @@
  * --------------------------------------------------------------------------
  * HISTORY:
  *
+ * 2018-07-08  (Anton Maklakov)
+ *   - Add "fall through" markers for GCC's -Wimplicit-fallthrough
+ *
+ * 2017-11-03  (Sebastian Pipping)
+ *   - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined
+ *
  * 2017-07-25  (Vadim Zeitlin)
  *   - Fix use of SIPHASH_MAIN macro
  *
@@ -151,6 +157,8 @@ static struct sipkey *sip_tokey(struct sipkey *key, const void *src) {
 } /* sip_tokey() */
 
 
+#ifdef SIPHASH_TOBIN
+
 #define sip_binof(v) sip_tobin((unsigned char[8]){ 0 }, (v))
 
 static void *sip_tobin(void *dst, uint64_t u64) {
@@ -158,6 +166,8 @@ static void *sip_tobin(void *dst, uint64_t u64) {
 	return dst;
 } /* sip_tobin() */
 
+#endif  /* SIPHASH_TOBIN */
+
 
 static void sip_round(struct siphash *H, const int rounds) {
 	int i;
@@ -231,12 +241,19 @@ static uint64_t sip24_final(struct siphash *H) {
 
 	switch (left) {
 	case 7: b |= (uint64_t)H->buf[6] << 48;
+		/* fall through */
 	case 6: b |= (uint64_t)H->buf[5] << 40;
+		/* fall through */
 	case 5: b |= (uint64_t)H->buf[4] << 32;
+		/* fall through */
 	case 4: b |= (uint64_t)H->buf[3] << 24;
+		/* fall through */
 	case 3: b |= (uint64_t)H->buf[2] << 16;
+		/* fall through */
 	case 2: b |= (uint64_t)H->buf[1] << 8;
+		/* fall through */
 	case 1: b |= (uint64_t)H->buf[0] << 0;
+		/* fall through */
 	case 0: break;
 	}
 
diff --git a/ThirdParty/expat/vtkexpat/lib/xmlparse.c b/ThirdParty/expat/vtkexpat/lib/xmlparse.c
index 90a237f30eb8cdcee92874d2cdc4b3d5e42e757c..c4f3ffc215c9ef9b3f385a9fc6e3199236e99b5a 100644
--- a/ThirdParty/expat/vtkexpat/lib/xmlparse.c
+++ b/ThirdParty/expat/vtkexpat/lib/xmlparse.c
@@ -1,4 +1,4 @@
-/* 4b74aa710b4ed5ce464b0ce544852cb47bf905c85a49c7bae2749f5885cb966d (2.2.5+)
+/* 19ac4776051591216f1874e34ee99b6a43a3784c8bd7d70efeb9258dd22b906a (2.2.6+)
                             __  __            _
                          ___\ \/ /_ __   __ _| |_
                         / _ \\  /| '_ \ / _` | __|
@@ -161,6 +161,9 @@ typedef char ICHAR;
 /* Round up n to be a multiple of sz, where sz is a power of 2. */
 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
 
+/* Do safe (NULL-aware) pointer arithmetic */
+#define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0)
+
 /* Handle the case where memmove() doesn't exist. */
 #ifndef HAVE_MEMMOVE
 #ifdef HAVE_BCOPY
@@ -1820,6 +1823,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
       parser->m_errorCode = XML_ERROR_NO_MEMORY;
       return XML_STATUS_ERROR;
     }
+    /* fall through */
   default:
     parser->m_parsingStatus.parsing = XML_PARSING;
   }
@@ -1969,6 +1973,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
       parser->m_errorCode = XML_ERROR_NO_MEMORY;
       return XML_STATUS_ERROR;
     }
+    /* fall through */
   default:
     parser->m_parsingStatus.parsing = XML_PARSING;
   }
@@ -2026,39 +2031,46 @@ XML_GetBuffer(XML_Parser parser, int len)
   default: ;
   }
 
-  if (len > parser->m_bufferLim - parser->m_bufferEnd) {
+  if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) {
 #ifdef XML_CONTEXT_BYTES
     int keep;
 #endif  /* defined XML_CONTEXT_BYTES */
     /* Do not invoke signed arithmetic overflow: */
-    int neededSize = (int) ((unsigned)len + (unsigned)(parser->m_bufferEnd - parser->m_bufferPtr));
+    int neededSize = (int) ((unsigned)len +
+                            (unsigned)EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd,
+                                                          parser->m_bufferPtr));
     if (neededSize < 0) {
       parser->m_errorCode = XML_ERROR_NO_MEMORY;
       return NULL;
     }
 #ifdef XML_CONTEXT_BYTES
-    keep = (int)(parser->m_bufferPtr - parser->m_buffer);
+    keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
     if (keep > XML_CONTEXT_BYTES)
       keep = XML_CONTEXT_BYTES;
     neededSize += keep;
 #endif  /* defined XML_CONTEXT_BYTES */
-    if (neededSize  <= parser->m_bufferLim - parser->m_buffer) {
+    if (neededSize <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) {
 #ifdef XML_CONTEXT_BYTES
-      if (keep < parser->m_bufferPtr - parser->m_buffer) {
-        int offset = (int)(parser->m_bufferPtr - parser->m_buffer) - keep;
+      if (keep < EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)) {
+          int offset = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer) - keep;
+        /* The buffer pointers cannot be NULL here; we have at least some bytes in the buffer */
         memmove(parser->m_buffer, &parser->m_buffer[offset], parser->m_bufferEnd - parser->m_bufferPtr + keep);
         parser->m_bufferEnd -= offset;
         parser->m_bufferPtr -= offset;
       }
 #else
-      memmove(parser->m_buffer, parser->m_bufferPtr, parser->m_bufferEnd - parser->m_bufferPtr);
-      parser->m_bufferEnd = parser->m_buffer + (parser->m_bufferEnd - parser->m_bufferPtr);
-      parser->m_bufferPtr = parser->m_buffer;
+      if (parser->m_buffer && parser->m_bufferPtr) {
+        memmove(parser->m_buffer, parser->m_bufferPtr,
+                EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
+        parser->m_bufferEnd = parser->m_buffer +
+            EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
+        parser->m_bufferPtr = parser->m_buffer;
+      }
 #endif  /* not defined XML_CONTEXT_BYTES */
     }
     else {
       char *newBuf;
-      int bufferSize = (int)(parser->m_bufferLim - parser->m_bufferPtr);
+      int bufferSize = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferPtr);
       if (bufferSize == 0)
         bufferSize = INIT_BUFFER_SIZE;
       do {
@@ -2077,25 +2089,34 @@ XML_GetBuffer(XML_Parser parser, int len)
       parser->m_bufferLim = newBuf + bufferSize;
 #ifdef XML_CONTEXT_BYTES
       if (parser->m_bufferPtr) {
-        int keep = (int)(parser->m_bufferPtr - parser->m_buffer);
+        int keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
         if (keep > XML_CONTEXT_BYTES)
           keep = XML_CONTEXT_BYTES;
-        memcpy(newBuf, &parser->m_bufferPtr[-keep], parser->m_bufferEnd - parser->m_bufferPtr + keep);
+        memcpy(newBuf, &parser->m_bufferPtr[-keep],
+               EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep);
         FREE(parser, parser->m_buffer);
         parser->m_buffer = newBuf;
-        parser->m_bufferEnd = parser->m_buffer + (parser->m_bufferEnd - parser->m_bufferPtr) + keep;
+        parser->m_bufferEnd = parser->m_buffer +
+            EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep;
         parser->m_bufferPtr = parser->m_buffer + keep;
       }
       else {
-        parser->m_bufferEnd = newBuf + (parser->m_bufferEnd - parser->m_bufferPtr);
+        /* This must be a brand new buffer with no data in it yet */
+        parser->m_bufferEnd = newBuf;
         parser->m_bufferPtr = parser->m_buffer = newBuf;
       }
 #else
       if (parser->m_bufferPtr) {
-        memcpy(newBuf, parser->m_bufferPtr, parser->m_bufferEnd - parser->m_bufferPtr);
+        memcpy(newBuf, parser->m_bufferPtr,
+               EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
         FREE(parser, parser->m_buffer);
+        parser->m_bufferEnd = newBuf +
+            EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
+      }
+      else {
+        /* This must be a brand new buffer with no data in it yet */
+        parser->m_bufferEnd = newBuf;
       }
-      parser->m_bufferEnd = newBuf + (parser->m_bufferEnd - parser->m_bufferPtr);
       parser->m_bufferPtr = parser->m_buffer = newBuf;
 #endif  /* not defined XML_CONTEXT_BYTES */
     }
@@ -2908,9 +2929,11 @@ doContent(XML_Parser parser,
         poolClear(&parser->m_tempPool);
         freeBindings(parser, bindings);
       }
-      if ((parser->m_tagLevel == 0) &&
-          !((parser->m_parsingStatus.parsing == XML_FINISHED) || (parser->m_parsingStatus.parsing == XML_SUSPENDED))) {
-        return epilogProcessor(parser, next, end, nextPtr);
+      if ((parser->m_tagLevel == 0) && (parser->m_parsingStatus.parsing != XML_FINISHED)) {
+        if (parser->m_parsingStatus.parsing == XML_SUSPENDED)
+          parser->m_processor = epilogProcessor;
+        else
+          return epilogProcessor(parser, next, end, nextPtr);
       }
       break;
     case XML_TOK_END_TAG:
@@ -4746,8 +4769,8 @@ doProlog(XML_Parser parser,
           return XML_ERROR_NO_MEMORY;
         parser->m_declEntity->publicId = NULL;
       }
-      /* fall through */
 #endif /* XML_DTD */
+      /* fall through */
     case XML_ROLE_ENTITY_SYSTEM_ID:
       if (dtd->keepProcessing && parser->m_declEntity) {
         parser->m_declEntity->systemId = poolStoreString(&dtd->pool, enc,
@@ -6643,7 +6666,6 @@ hash(XML_Parser parser, KEY s)
 {
   struct siphash state;
   struct sipkey key;
-  (void)sip_tobin;
   (void)sip24_valid;
   copy_salt_to_sipkey(parser, &key);
   sip24_init(&state, &key);
diff --git a/ThirdParty/expat/vtkexpat/lib/xmltok_impl.c b/ThirdParty/expat/vtkexpat/lib/xmltok_impl.c
index 0403dd3d09a0b6ff6203ed8aa6e89d4e3f07c34c..4d9ae7dc3896b8393f8b41eeb98becdcb3bcaa46 100644
--- a/ThirdParty/expat/vtkexpat/lib/xmltok_impl.c
+++ b/ThirdParty/expat/vtkexpat/lib/xmltok_impl.c
@@ -74,6 +74,7 @@
       *nextTokPtr = ptr; \
       return XML_TOK_INVALID; \
     } \
+    /* fall through */ \
   case BT_NMSTRT: \
   case BT_HEX: \
   case BT_DIGIT: \
@@ -102,6 +103,7 @@
       *nextTokPtr = ptr; \
       return XML_TOK_INVALID; \
     } \
+    /* fall through */ \
   case BT_NMSTRT: \
   case BT_HEX: \
     ptr += MINBPC(enc); \
@@ -602,7 +604,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
           return XML_TOK_INVALID;
         }
       }
-    /* fall through */
+      /* fall through */
     case BT_EQUALS:
       {
         int open;
@@ -1442,6 +1444,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
     case BT_NMSTRT:
       if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
         break;
+      /* fall through */
     default:
       switch (BYTE_TO_ASCII(enc, ptr)) {
       case 0x24: /* $ */
@@ -1659,8 +1662,8 @@ PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
 {
   for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
     if (end1 - ptr1 < MINBPC(enc)) {
-      /* This line cannot be executed.  THe incoming data has already
-       * been tokenized once, so imcomplete characters like this have
+      /* This line cannot be executed.  The incoming data has already
+       * been tokenized once, so incomplete characters like this have
        * already been eliminated from the input.  Retaining the
        * paranoia check is still valuable, however.
        */