[PATCH 1/3] libX11/lcGenConv.c fix: dereferenced before check

walter harms wharms at bfs.de
Wed Jun 4 08:08:12 PDT 2014


* Do not use variables before checked for NULL.

Signed-off-by: Harms <wharms at bfs,de>
---
 modules/lc/gen/lcGenConv.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/lc/gen/lcGenConv.c b/modules/lc/gen/lcGenConv.c
index 1f7c301..76a91bb 100644
--- a/modules/lc/gen/lcGenConv.c
+++ b/modules/lc/gen/lcGenConv.c
@@ -753,7 +753,7 @@ mbstowcs_org(

     CodeSet codeset = NULL;

-    const char *inbufptr = *from;
+    const char *inbufptr;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;

@@ -764,6 +764,8 @@ mbstowcs_org(
         return( 0 );
     }

+    inbufptr = *from;
+
     while (*from_left && *to_left) {

 	ch = *inbufptr++;
@@ -1252,7 +1254,7 @@ ctstowcs(
     CodeSet codeset = NULL;
     XlcCharSet charset_tmp;

-    const char *inbufptr = *from;
+    const char *inbufptr;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;

@@ -1262,6 +1264,7 @@ ctstowcs(
 	_XlcResetConverter(conv);
         return( 0 );
     }
+    inbufptr = *from;

     while (*from_left && *to_left) {

@@ -1437,7 +1440,7 @@ cstowcs(
     CodeSet codeset = NULL;
     XlcCharSet charset, charset_tmp;

-    const char *inbufptr = *from;
+    const char *inbufptr;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;

@@ -1445,6 +1448,8 @@ cstowcs(
         return( 0 );
     }

+    inbufptr = *from;
+
     charset = (XlcCharSet) args[0];

     while (*from_left && *to_left) {
@@ -1643,7 +1648,7 @@ mbstostr(

     CodeSet codeset = NULL;

-    const char *inbufptr = *from;
+    const char *inbufptr;
     char *outbufptr = *to;
     int from_size = *from_left;

@@ -1654,6 +1659,8 @@ mbstostr(
         return( 0 );
     }

+    inbufptr = *from;
+
     while (*from_left && *to_left) {

 	ch = *inbufptr++;
@@ -1758,7 +1765,7 @@ mbtocs(
     CodeSet codeset = NULL;
     XlcCharSet charset = NULL;

-    const char *inbufptr = *from;
+    const char *inbufptr;
     char *outbufptr = *to;
     int from_size = *from_left;

@@ -1769,6 +1776,8 @@ mbtocs(
         return( 0 );
     }

+    inbufptr = *from;
+
     while (*from_left && *to_left) {

 	ch = *inbufptr++;
-- 
1.8.4.5



More information about the xorg-devel mailing list