]> git.sesse.net Git - vlc/commitdiff
Fix a possible segfault patch by Brian Robb
authorChristophe Mutricy <xtophe@videolan.org>
Fri, 9 Sep 2005 16:55:37 +0000 (16:55 +0000)
committerChristophe Mutricy <xtophe@videolan.org>
Fri, 9 Sep 2005 16:55:37 +0000 (16:55 +0000)
src/extras/libc.c

index b74647470faf8a08422eb526058e705b5a1ef2f2..e5c3e68c59a032207289472c0d610a9d0b66a274 100644 (file)
@@ -29,6 +29,7 @@
 #include <ctype.h>
 
 #include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #undef iconv_t
 #undef iconv_open
@@ -612,7 +613,14 @@ size_t vlc_iconv( vlc_iconv_t cd, char **inbuf, size_t *inbytesleft,
 #if defined(HAVE_ICONV)
     return iconv( cd, inbuf, inbytesleft, outbuf, outbytesleft );
 #else
-    int i_bytes = __MIN(*inbytesleft, *outbytesleft);
+    int i_bytes;
+
+    if (inbytesleft == NULL || outbytesleft == NULL)
+    {
+        return 0;
+    }
+
+    i_bytes = __MIN(*inbytesleft, *outbytesleft);
     if( !inbuf || !outbuf || !i_bytes ) return (size_t)(-1);
     memcpy( *outbuf, *inbuf, i_bytes );
     inbuf += i_bytes;