diff --git a/cbits/common/sysdefs.h b/cbits/common/sysdefs.h
--- a/cbits/common/sysdefs.h
+++ b/cbits/common/sysdefs.h
@@ -23,17 +23,29 @@
 #	include <config.h>
 #endif
 
-// This #define ensures that C99 and POSIX compliant stdio functions are
-// available with MinGW-w64 (both 32-bit and 64-bit). Modern MinGW-w64 adds
-// this automatically, for example, when the compiler is in C99 (or later)
-// mode when building against msvcrt.dll. It still doesn't hurt to be explicit
-// that we always want this and #define this unconditionally.
+// Choose if MinGW-w64's stdio replacement functions should be used.
+// The default has varied slightly in the past so it's clearest to always
+// set it explicitly.
 //
-// With Universal CRT (UCRT) this is less important because UCRT contains
-// C99-compatible stdio functions. It's still nice to #define this as UCRT
-// doesn't support the POSIX thousand separator flag in printf (like "%'u").
-#ifdef __MINGW32__
+// Modern MinGW-w64 enables the replacement functions even with UCRT
+// when _GNU_SOURCE is defined. That's good because UCRT doesn't support
+// the POSIX thousand separator flag in printf (like "%'u"). Otherwise
+// XZ Utils works with the UCRT stdio functions.
+//
+// The replacement functions add over 20 KiB to each executable. For
+// size-optimized builds (HAVE_SMALL), disable the replacements.
+// Then thousand separators aren't shown in xz's messages but this is
+// a minor downside compare to the slower speed of the HAVE_SMALL builds.
+//
+// The legacy MSVCRT is pre-C99 and it's best to always use the stdio
+// replacements functions from MinGW-w64.
+#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #	define __USE_MINGW_ANSI_STDIO 1
+#	include <_mingw.h>
+#	if defined(_UCRT) && defined(HAVE_SMALL)
+#		undef __USE_MINGW_ANSI_STDIO
+#		define __USE_MINGW_ANSI_STDIO 0
+#	endif
 #endif
 
 // size_t and NULL
diff --git a/cbits/common/tuklib_mbstr_width.c b/cbits/common/tuklib_mbstr_width.c
--- a/cbits/common/tuklib_mbstr_width.c
+++ b/cbits/common/tuklib_mbstr_width.c
@@ -12,7 +12,7 @@
 #include "tuklib_mbstr.h"
 #include <string.h>
 
-#if defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
+#ifdef HAVE_MBRTOWC
 #	include <wchar.h>
 #endif
 
@@ -24,7 +24,7 @@
 	if (bytes != NULL)
 		*bytes = len;
 
-#if !(defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH))
+#ifndef HAVE_MBRTOWC
 	// In single-byte mode, the width of the string is the same
 	// as its length.
 	return len;
@@ -46,11 +46,20 @@
 
 		i += ret;
 
+#ifdef HAVE_WCWIDTH
 		const int wc_width = wcwidth(wc);
 		if (wc_width < 0)
 			return (size_t)-1;
 
 		width += (size_t)wc_width;
+#else
+		// Without wcwidth() (like in a native Windows build),
+		// assume that one multibyte char == one column. With
+		// UTF-8, this is less bad than one byte == one column.
+		// This way quite a few languages will be handled correctly
+		// in practice; CJK chars will be very wrong though.
+		++width;
+#endif
 	}
 
 	// Require that the string ends in the initial shift state.
diff --git a/cbits/liblzma/api/lzma/lzma12.h b/cbits/liblzma/api/lzma/lzma12.h
--- a/cbits/liblzma/api/lzma/lzma12.h
+++ b/cbits/liblzma/api/lzma/lzma12.h
@@ -461,7 +461,7 @@
 	 *
 	 * ext_size_low holds the least significant 32 bits of the
 	 * uncompressed size. The most significant 32 bits must be set
-	 * in ext_size_high. The macro lzma_ext_size_set(opt_lzma, u64size)
+	 * in ext_size_high. The macro lzma_set_ext_size(opt_lzma, u64size)
 	 * can be used to set these members.
 	 *
 	 * The 64-bit uncompressed size is split into two uint32_t variables
diff --git a/cbits/liblzma/api/lzma/version.h b/cbits/liblzma/api/lzma/version.h
--- a/cbits/liblzma/api/lzma/version.h
+++ b/cbits/liblzma/api/lzma/version.h
@@ -22,7 +22,7 @@
 #define LZMA_VERSION_MINOR 6
 
 /** \brief Patch version number of the liblzma release. */
-#define LZMA_VERSION_PATCH 3
+#define LZMA_VERSION_PATCH 4
 
 /**
  * \brief Version stability marker
diff --git a/cbits/liblzma/common/memcmplen.h b/cbits/liblzma/common/memcmplen.h
--- a/cbits/liblzma/common/memcmplen.h
+++ b/cbits/liblzma/common/memcmplen.h
@@ -65,8 +65,7 @@
 			|| (defined(_MSC_VER) && (defined(_M_X64) \
 				|| defined(_M_ARM64) || defined(_M_ARM64EC))))
 	// This is only for x86-64 and ARM64 for now. This might be fine on
-	// other 64-bit processors too. On big endian one should use xor
-	// instead of subtraction and switch to __builtin_clzll().
+	// other 64-bit processors too.
 	//
 	// Reasons to use subtraction instead of xor:
 	//
@@ -82,7 +81,11 @@
 	// version 2023-05-26. https://www.agner.org/optimize/
 #define LZMA_MEMCMPLEN_EXTRA 8
 	while (len < limit) {
+#	ifdef WORDS_BIGENDIAN
+		const uint64_t x = read64ne(buf1 + len) ^ read64ne(buf2 + len);
+#	else
 		const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len);
+#	endif
 		if (x != 0) {
 	// MSVC or Intel C compiler on Windows
 #	if defined(_MSC_VER) || defined(__INTEL_COMPILER)
@@ -90,6 +93,8 @@
 			_BitScanForward64(&tmp, x);
 			len += (uint32_t)tmp >> 3;
 	// GCC, Clang, or Intel C compiler
+#	elif defined(WORDS_BIGENDIAN)
+			len += (uint32_t)__builtin_clzll(x) >> 3;
 #	else
 			len += (uint32_t)__builtin_ctzll(x) >> 3;
 #	endif
diff --git a/cbits/liblzma/common/string_conversion.c b/cbits/liblzma/common/string_conversion.c
--- a/cbits/liblzma/common/string_conversion.c
+++ b/cbits/liblzma/common/string_conversion.c
@@ -317,6 +317,10 @@
 		uint32_t *preset)
 {
 	assert(*str < str_end);
+
+	if (!(**str >= '0' && **str <= '9'))
+		return "Unsupported preset";
+
 	*preset = (uint32_t)(**str - '0');
 
 	// NOTE: Remember to update LZMA12_PRESET_STR if this is modified!
diff --git a/cbits/liblzma/lzma/lzma_decoder.c b/cbits/liblzma/lzma/lzma_decoder.c
--- a/cbits/liblzma/lzma/lzma_decoder.c
+++ b/cbits/liblzma/lzma/lzma_decoder.c
@@ -18,7 +18,7 @@
 
 // The macros unroll loops with switch statements.
 // Silence warnings about missing fall-through comments.
-#if TUKLIB_GNUC_REQ(7, 0)
+#if TUKLIB_GNUC_REQ(7, 0) || defined(__clang__)
 #	pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
 #endif
 
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.72 for XZ Utils 5.6.3.
+# Generated by GNU Autoconf 2.72 for XZ Utils 5.6.4.
 #
 # Report bugs to <lasse.collin@tukaani.org>.
 #
@@ -614,8 +614,8 @@
 # Identity of this package.
 PACKAGE_NAME='XZ Utils'
 PACKAGE_TARNAME='xz'
-PACKAGE_VERSION='5.6.3'
-PACKAGE_STRING='XZ Utils 5.6.3'
+PACKAGE_VERSION='5.6.4'
+PACKAGE_STRING='XZ Utils 5.6.4'
 PACKAGE_BUGREPORT='lasse.collin@tukaani.org'
 PACKAGE_URL='https://tukaani.org/xz/'
 
@@ -1523,7 +1523,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-'configure' configures XZ Utils 5.6.3 to adapt to many kinds of systems.
+'configure' configures XZ Utils 5.6.4 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1589,7 +1589,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of XZ Utils 5.6.3:";;
+     short | recursive ) echo "Configuration of XZ Utils 5.6.4:";;
    esac
   cat <<\_ACEOF
 
@@ -1794,7 +1794,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-XZ Utils configure 5.6.3
+XZ Utils configure 5.6.4
 generated by GNU Autoconf 2.72
 
 Copyright (C) 2023 Free Software Foundation, Inc.
@@ -2614,7 +2614,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by XZ Utils $as_me 5.6.3, which was
+It was created by XZ Utils $as_me 5.6.4, which was
 generated by GNU Autoconf 2.72.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -22741,7 +22741,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by XZ Utils $as_me 5.6.3, which was
+This file was extended by XZ Utils $as_me 5.6.4, which was
 generated by GNU Autoconf 2.72.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -22801,7 +22801,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-XZ Utils config.status 5.6.3
+XZ Utils config.status 5.6.4
 configured by $0, generated by GNU Autoconf 2.72,
   with options \\"\$ac_cs_config\\"
 
diff --git a/xz-clib.cabal b/xz-clib.cabal
--- a/xz-clib.cabal
+++ b/xz-clib.cabal
@@ -1,6 +1,6 @@
 cabal-version:       2.2
 name:                xz-clib
-version:             5.6.3
+version:             5.6.4
 
 synopsis:            LZMA/XZ clibs
 description:         C source code for the LZMA/XZ compression and decompression library
