From b1890d012c0483feedb4e8b530fba26e49ced3cd Mon Sep 17 00:00:00 2001
From: "Paul \"Dettorer\" Hervot"
Date: Sun, 29 Nov 2015 11:48:39 +0100
Subject: [PATCH] String_util: Explicitly use a const_cast when calling iconv
---
src/common/string_util.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index ca671ab12..2feb94c8a 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -391,8 +391,14 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string&
while (0 != src_bytes)
{
- size_t const iconv_result = iconv(conv_desc, (char**)(&src_buffer), &src_bytes,
- &dst_buffer, &dst_bytes);
+ const char** iconv_inbuff = reinterpret_cast(&src_buffer);
+
+ // This const_cast is here because iconv declares its second argument as
+ // "char**" where it should be "const char**" because the only thing
+ // actually modified is the pointer, hence the const_cast.
+ const size_t iconv_result = iconv(conv_desc,
+ const_cast(iconv_inbuff),
+ &src_bytes, &dst_buffer, &dst_bytes);
if (static_cast(-1) == iconv_result)
{