Sorry it took so long to get back to this.
I wonder if this crash accounts for Henry Thompson's report, too?
Jerry James writes:
We need to notice the Lstream_read failure and bail out of
determine_real_coding_system.
--- a/src/file-coding.c Thu Mar 27 08:59:03 2014 -0600
+++ b/src/file-coding.c Thu Mar 27 09:32:53 2014 -0600
In encode_decode_coding_region:
@@ -2294,7 +2294,7 @@
Bytecount size_in_bytes =
Lstream_read (istr, tempbuf, sizeof (tempbuf));
- if (!size_in_bytes)
+ if (size_in_bytes <= 0)
break;
newpos = lisp_buffer_stream_startpos (istr);
Lstream_write (ostr, tempbuf, size_in_bytes);
I don't think this is sufficient. The calling code is expecting the
Lstream_write to succeed. If it fails due to an error, that error
should be signaled, because the user's data may be corrupt. I don't
think that the buffer is corrupt in the sense that there are bytes
that aren't in Mule internal encoding, but I'm not entirely sure of
that, and don't have time to make sure right now.
@@ -3863,24 +3863,32 @@
make_opaque_ptr (st));
UExtbyte buf[4096];
Bytecount nread = Lstream_read (stream, buf, sizeof (buf));
- Lisp_Object coding_system
- = look_for_coding_system_magic_cookie (buf, nread, 1);
-
- if (NILP (coding_system))
+ Lisp_Object coding_system;
+
+ if (nread > 0)
{
- while (1)
+ coding_system = look_for_coding_system_magic_cookie (buf, nread, 1);
+
+ if (NILP (coding_system))
{
- if (detect_coding_type (st, buf, nread))
- break;
- nread = Lstream_read (stream, buf, sizeof (buf));
- if (nread == 0)
- break;
+ while (1)
+ {
+ if (detect_coding_type (st, buf, nread))
+ break;
+ nread = Lstream_read (stream, buf, sizeof (buf));
+ if (nread <= 0)
+ break;
I worry about this simple change from "nread == 0" to "nread <=
0".
If there is a read error, shouldn't the user be told about it?
I suspect that a read error here is an XEmacs bug elsewhere.
Specifically, I think that the coding system should catch and report
the error (again, I need to check that).
+ }
+
+ coding_system = detected_coding_system (st);
}
- coding_system = detected_coding_system (st);
+ Lstream_rewind (stream);
}
-
- Lstream_rewind (stream);
+ else
+ {
+ coding_system = Qnil;
+ }
unbind_to (depth);
return coding_system;
@@ -4315,7 +4323,9 @@
Lstream_delete (XLSTREAM (lstream));
retry_close (fd);
- return look_for_coding_system_magic_cookie (buf, nread, 0);
+ return (nread > 0)
+ ? look_for_coding_system_magic_cookie (buf, nread, 0)
+: Qnil;
}
I'm almost tempted to suggest putting the checking logic in
look_for_coding_system_magic_cookie.
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta