[vlc-devel] commit: Remove duplication and do the NULL text before dereferencing ( CID 232) ( Rémi Duraffort )

git version control git at videolan.org
Thu Oct 2 21:13:30 CEST 2008


vlc | branch: 0.9-bugfix | Rémi Duraffort <ivoire at videolan.org> | Wed Oct  1 20:34:56 2008 +0200| [8cb547f549c5980a86acfa9171def7df75312ab0] | committer: Derk-Jan Hartman 

Remove duplication and do the NULL text before dereferencing (CID 232)
(cherry picked from commit 78277aedce99a6ca8f69844b5a93b70aa95a7ede)

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

 src/text/unicode.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/text/unicode.c b/src/text/unicode.c
index 036027c..6f36db4 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -99,6 +99,9 @@ static int find_charset (void)
 
 static char *locale_fast (const char *string, bool from)
 {
+    if( string == NULL )
+        return NULL;
+
 #if defined (USE_ICONV)
     if (find_charset ())
         return (char *)string;
@@ -113,9 +116,6 @@ static char *locale_fast (const char *string, bool from)
     size_t outb = inb * 6 + 1;
     char output[outb], *optr = output;
 
-    if (string == NULL)
-        return NULL;
-
     while (vlc_iconv (hd, &iptr, &inb, &optr, &outb) == (size_t)(-1))
     {
         *optr++ = '?';
@@ -136,9 +136,6 @@ static char *locale_fast (const char *string, bool from)
     char *out;
     int len;
 
-    if (string == NULL)
-        return NULL;
-
     len = 1 + MultiByteToWideChar (from ? CP_ACP : CP_UTF8,
                                    0, string, -1, NULL, 0);
     wchar_t wide[len];




More information about the vlc-devel mailing list