about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--iconvdata/iso-2022-jp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c
index ecfdae4e47..fc34aaba96 100644
--- a/iconvdata/iso-2022-jp.c
+++ b/iconvdata/iso-2022-jp.c
@@ -577,6 +577,12 @@ gconv_end (struct __gconv_step *data)
       {									      \
 	if (set2 == ISO88591_set)					      \
 	  {								      \
+	    if (__builtin_expect (outptr + 3 > outend, 0))		      \
+	      {								      \
+		result = __GCONV_FULL_OUTPUT;				      \
+		break;							      \
+	      }								      \
+									      \
 	    if (ch >= 0x80 && ch <= 0xff) 				      \
 	      {								      \
 		*outptr++ = ESC;					      \
@@ -596,6 +602,12 @@ gconv_end (struct __gconv_step *data)
 		unsigned char res = iso88597_from_ucs4[ch - 0xa0 + rp->idx];  \
 		if (res != '\0')					      \
 		  {							      \
+		    if (__builtin_expect (outptr + 3 > outend, 0))	      \
+		      {							      \
+			result = __GCONV_FULL_OUTPUT;			      \
+			break;						      \
+		      }							      \
+									      \
 		    *outptr++ = ESC;					      \
 		    *outptr++ = 'N';					      \
 		    *outptr++ = res;					      \