Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it
reads a file that ends with incomplete sequence and sizehint argument
for .read() is specified.
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 7c6b989..9fb9570 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1214,6 +1214,8 @@
 	cres = NULL;
 
 	for (;;) {
+		int endoffile;
+
 		if (sizehint < 0)
 			cres = PyObject_CallMethod(self->stream,
 					(char *)method, NULL);
@@ -1230,6 +1232,8 @@
 			goto errorexit;
 		}
 
+		endoffile = (PyString_GET_SIZE(cres) == 0);
+
 		if (self->pendingsize > 0) {
 			PyObject *ctr;
 			char *ctrdata;
@@ -1257,7 +1261,7 @@
 				(MultibyteStatefulDecoderContext *)self, &buf))
 			goto errorexit;
 
-		if (rsize == 0 || sizehint < 0) { /* end of file */
+		if (endoffile || sizehint < 0) {
 			if (buf.inbuf < buf.inbuf_end &&
 			    multibytecodec_decerror(self->codec, &self->state,
 					&buf, self->errors, MBERR_TOOFEW))