From 92d8324cdc688501caa68670ce3523e949db6ed1 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 28 Feb 2023 21:01:23 +0100 Subject: [PATCH] Improve condition for use of `pubsetbuf` Using this function like this seems only be possible with `libstdc++`. The standard lib of MSVC does not support it as well. So use it only with `libstdc++`. --- io/passwordfile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index da03ae3..2486872 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -349,10 +349,10 @@ void PasswordFile::load() stringstream decryptedStream(stringstream::in | stringstream::out | stringstream::binary); decryptedStream.exceptions(ios_base::failbit | ios_base::badbit); try { -#ifdef _LIBCPP_VERSION - decryptedStream.write(decryptedData.data(), static_cast(remainingSize)); -#else +#if defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) decryptedStream.rdbuf()->pubsetbuf(decryptedData.data(), static_cast(remainingSize)); +#else + decryptedStream.write(decryptedData.data(), static_cast(remainingSize)); #endif if (m_version >= 0x5u) { BinaryReader reader(&decryptedStream);