diff --git a/src/process.c b/src/process.c index 2376d0f288d..91a5c044a8c 100644 --- a/src/process.c +++ b/src/process.c @@ -6128,11 +6133,11 @@ read_and_dispose_of_process_output (struct Lisp_Process *p, char *chars, static int read_process_output (Lisp_Object proc, int channel) { - ssize_t nbytes; + ssize_t nbytes, nnbytes = 0; struct Lisp_Process *p = XPROCESS (proc); eassert (0 <= channel && channel < FD_SETSIZE); struct coding_system *coding = proc_decode_coding_system[channel]; - int carryover = p->decoding_carryover; + int carryover; ptrdiff_t readmax = clip_to_bounds (1, read_process_output_max, PTRDIFF_MAX); specpdl_ref count = SPECPDL_INDEX (); Lisp_Object odeactivate; @@ -6141,6 +6146,9 @@ read_process_output (Lisp_Object proc, int channel) USE_SAFE_ALLOCA; chars = SAFE_ALLOCA (sizeof coding->carryover + readmax); +do{ + carryover = p->decoding_carryover; + if (carryover) /* See the comment above. */ memcpy (chars, SDATA (p->decoding_buf), carryover); @@ -6222,3 +6236,3 @@ read_process_output (Lisp_Object proc, int channel) /* Now set NBYTES how many bytes we must decode. */ nbytes += carryover; @@ -6233,5 +6245,8 @@ /* Handling the process output should not deactivate the mark. */ Vdeactivate_mark = odeactivate; + nnbytes += nbytes; + } while (nbytes >= readmax); + SAFE_FREE_UNBIND_TO (count, Qnil); - return nbytes; + return nnbytes; }