# HG changeset patch # User stephent # Date 1098960100 0 # Node ID 186992a01a13b3e88c8a0a88a625e2f9d2d62054 # Parent cae9d7b3fe76ce6b7ba3da4387870a47462970a1 [xemacs-hg @ 2004-10-28 10:41:35 by stephent] fix record-buffer crash <87u0sf2ksj.fsf_-_@tleepslib.sk.tsukuba.ac.jp> diff -r cae9d7b3fe76 -r 186992a01a13 src/ChangeLog --- a/src/ChangeLog Wed Oct 27 21:52:28 2004 +0000 +++ b/src/ChangeLog Thu Oct 28 10:41:40 2004 +0000 @@ -1,3 +1,10 @@ +2004-09-02 Yoshiki Hayashi + + * buffer.c (Frecord_buffer): Make sure the argument is buffer + to fix a crash. Also, check the buffer is live and it + really exists in buffer_list. If the buffer is not in the list, + prepend it. + 2004-10-22 Stephen J. Turnbull * XEmacs 21.5.18 "chestnut" is released. diff -r cae9d7b3fe76 -r 186992a01a13 src/buffer.c --- a/src/buffer.c Wed Oct 27 21:52:28 2004 +0000 +++ b/src/buffer.c Thu Oct 28 10:41:40 2004 +0000 @@ -1374,38 +1374,60 @@ { REGISTER Lisp_Object lynk, prev; struct frame *f = selected_frame (); - + int buffer_found = 0; + + CHECK_BUFFER (buffer); + if (!BUFFER_LIVE_P (XBUFFER (buffer))) + return Qnil; prev = Qnil; for (lynk = Vbuffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ - if (NILP (prev)) - Vbuffer_alist = XCDR (Vbuffer_alist); + if (buffer_found) + { + /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ + if (NILP (prev)) + Vbuffer_alist = XCDR (Vbuffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = Vbuffer_alist; + Vbuffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = Vbuffer_alist; - Vbuffer_alist = lynk; + Vbuffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), Vbuffer_alist); /* That was the global one. Now do the same thing for the per-frame buffer-alist. */ + buffer_found = 0; prev = Qnil; for (lynk = f->buffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ - if (NILP (prev)) - f->buffer_alist = XCDR (f->buffer_alist); + if (buffer_found) + { + /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ + if (NILP (prev)) + f->buffer_alist = XCDR (f->buffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = f->buffer_alist; + f->buffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = f->buffer_alist; - f->buffer_alist = lynk; + f->buffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), + f->buffer_alist); return Qnil; }