From f4920abebc7b3c2b20acd072c5db1fb78117dcaf Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 31 May 2018 01:24:04 +0200 Subject: [PATCH] Fix thread-safety of character set conversion functions --- conversion/stringconversion.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conversion/stringconversion.cpp b/conversion/stringconversion.cpp index 82905cd..a2496a4 100644 --- a/conversion/stringconversion.cpp +++ b/conversion/stringconversion.cpp @@ -137,7 +137,7 @@ StringData convertString( */ StringData convertUtf8ToUtf16LE(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("UTF-8", "UTF-16LE"); + thread_local ConversionDescriptor descriptor("UTF-8", "UTF-16LE"); return descriptor.convertString(inputBuffer, inputBufferSize); } @@ -146,7 +146,7 @@ StringData convertUtf8ToUtf16LE(const char *inputBuffer, std::size_t inputBuffer */ StringData convertUtf16LEToUtf8(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("UTF-16LE", "UTF-8"); + thread_local ConversionDescriptor descriptor("UTF-16LE", "UTF-8"); return descriptor.convertString(inputBuffer, inputBufferSize); } @@ -155,7 +155,7 @@ StringData convertUtf16LEToUtf8(const char *inputBuffer, std::size_t inputBuffer */ StringData convertUtf8ToUtf16BE(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("UTF-8", "UTF-16BE"); + thread_local ConversionDescriptor descriptor("UTF-8", "UTF-16BE"); return descriptor.convertString(inputBuffer, inputBufferSize); } @@ -164,7 +164,7 @@ StringData convertUtf8ToUtf16BE(const char *inputBuffer, std::size_t inputBuffer */ StringData convertUtf16BEToUtf8(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("UTF-16BE", "UTF-8"); + thread_local ConversionDescriptor descriptor("UTF-16BE", "UTF-8"); return descriptor.convertString(inputBuffer, inputBufferSize); } @@ -173,7 +173,7 @@ StringData convertUtf16BEToUtf8(const char *inputBuffer, std::size_t inputBuffer */ StringData convertLatin1ToUtf8(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("ISO-8859-1", "UTF-8"); + thread_local ConversionDescriptor descriptor("ISO-8859-1", "UTF-8"); return descriptor.convertString(inputBuffer, inputBufferSize); } @@ -182,7 +182,7 @@ StringData convertLatin1ToUtf8(const char *inputBuffer, std::size_t inputBufferS */ StringData convertUtf8ToLatin1(const char *inputBuffer, std::size_t inputBufferSize) { - static ConversionDescriptor descriptor("UTF-8", "ISO-8859-1"); + thread_local ConversionDescriptor descriptor("UTF-8", "ISO-8859-1"); return descriptor.convertString(inputBuffer, inputBufferSize); }