[vlc-commits] vlc_iconv: avoid invalid casts

Rémi Denis-Courmont git at videolan.org
Wed Jun 21 20:03:48 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 21 21:03:05 2017 +0300| [11b66ab25fa3b219f7e2f858fc21d919f1bb2f2d] | committer: Rémi Denis-Courmont

vlc_iconv: avoid invalid casts

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=11b66ab25fa3b219f7e2f858fc21d919f1bb2f2d
---

 src/extras/libc.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/extras/libc.c b/src/extras/libc.c
index cccb469128..bb7faab769 100644
--- a/src/extras/libc.c
+++ b/src/extras/libc.c
@@ -382,17 +382,29 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
 size_t vlc_iconv( vlc_iconv_t cd, const char **inbuf, size_t *inbytesleft,
                   char **outbuf, size_t *outbytesleft )
 {
+    size_t ret;
+
 #ifndef __linux__
     if ( cd == (vlc_iconv_t)(-2) )
-        return ISO6937toUTF8( inbuf, inbytesleft,
-                              (unsigned char **)outbuf, outbytesleft );
+    {
+        unsigned char *out = (unsigned char *)*outbuf;
+
+        ret = ISO6937toUTF8( inbuf, inbytesleft, &out, outbytesleft );
+        *outbuf = (char *)out;
+    }
+    else
 #endif
 #if defined(HAVE_ICONV)
-    return iconv( cd, (ICONV_CONST char **)inbuf, inbytesleft,
-                  outbuf, outbytesleft );
+    {
+        ICONV_CONST char *cin = (ICONV_CONST char *)*inbuf;
+
+        ret = iconv( cd, &cin, inbytesleft, outbuf, outbytesleft );
+        *inbuf = cin;
+    }
 #else
-    abort ();
+        abort ();
 #endif
+    return ret;
 }
 
 int vlc_iconv_close( vlc_iconv_t cd )



More information about the vlc-commits mailing list