summary refs log tree commit diff
path: root/iconvdata
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-01-07 04:34:56 +0000
committerUlrich Drepper <drepper@redhat.com>2001-01-07 04:34:56 +0000
commit531950cebdce5556d5ad7fe3dcd74f78956f3161 (patch)
treee18c7987076b55ac5b58d4c847b81d73a36b26c0 /iconvdata
parente4a5f77de683578d85fe7621ebdaee76dd3df89c (diff)
downloadglibc-531950cebdce5556d5ad7fe3dcd74f78956f3161.tar.gz
glibc-531950cebdce5556d5ad7fe3dcd74f78956f3161.tar.xz
glibc-531950cebdce5556d5ad7fe3dcd74f78956f3161.zip
Update.
2001-01-06  Ulrich Drepper  <drepper@redhat.com>

	* iconvdata/ibm937.c (BODY to IBM937): Correct several mistakes in
	buffer and table handling.
Diffstat (limited to 'iconvdata')
-rw-r--r--iconvdata/ibm937.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/iconvdata/ibm937.c b/iconvdata/ibm937.c
index 6da55ae883..4fee56a506 100644
--- a/iconvdata/ibm937.c
+++ b/iconvdata/ibm937.c
@@ -188,13 +188,15 @@ enum
 									      \
     /* Use the UCS4 table for single byte.  */				      \
     cp = __ucs4_to_ibm937sb[ch];					      \
-    if (__builtin_expect (ch >= sizeof (__ucs4_to_ibm937sb)		      \
-			  / sizeof (__ucs4_to_ibm937sb[0]), 0)		      \
+    if (__builtin_expect (ch >= (sizeof (__ucs4_to_ibm937sb)		      \
+				 / sizeof (__ucs4_to_ibm937sb[0])), 0)	      \
 	|| (__builtin_expect (cp[0], '\1') == '\0' && ch != 0))		      \
       {									      \
 	/* Use the UCS4 table for double byte.  */			      \
 	cp = __ucs4_to_ibm937db[ch];					      \
-	if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
+	if (__builtin_expect (ch >= (sizeof (__ucs4_to_ibm937db)	      \
+				     / sizeof (__ucs4_to_ibm937db[0])), 0)    \
+	    || __builtin_expect (cp[0], '\1') == '\0')			      \
 	  {								      \
 	    /* This is an illegal character.  */			      \
 	    if (! ignore_errors_p ())					      \
@@ -209,13 +211,13 @@ enum
 	    if (curcs == sb)						      \
 	      {								      \
 		*outptr++ = SO;						      \
-		if (__builtin_expect (outptr == outend, 0))		      \
-		  {							      \
-		    result = __GCONV_FULL_OUTPUT;			      \
-		    break;						      \
-		  }							      \
 		curcs = db;						      \
 	      }								      \
+	    if (__builtin_expect (outptr + 1 >= outend, 0))		      \
+	      {								      \
+		result = __GCONV_FULL_OUTPUT;				      \
+		break;							      \
+	      }								      \
 	    *outptr++ = cp[0];						      \
 	    *outptr++ = cp[1];						      \
 	  }								      \
@@ -225,13 +227,13 @@ enum
 	if (curcs == db)						      \
 	  {								      \
 	    *outptr++ = SI;						      \
+	    curcs = sb;							      \
 	    if (__builtin_expect (outptr == outend, 0))			      \
 	      {								      \
 		result = __GCONV_FULL_OUTPUT;				      \
 		break;							      \
 	      }								      \
 	  }								      \
-	curcs = sb;							      \
 	*outptr++ = cp[0];						      \
       }									      \
 									      \