From xemacs-m  Sun Jun 29 02:05:09 1997
Received: from crystal.WonderWorks.COM (crystal.WonderWorks.com [192.203.206.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id CAA22207
	for <xemacs-beta@xemacs.org>; Sun, 29 Jun 1997 02:05:07 -0500 (CDT)
Received: by crystal.WonderWorks.COM 
	id QQcvzo13189; Sun, 29 Jun 1997 03:05:07 -0400 (EDT)
Date: Sun, 29 Jun 1997 03:05:07 -0400 (EDT)
Message-Id: <QQcvzo13189.199706290705@crystal.WonderWorks.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Kyle Jones <kyle_jones@wonderworks.com>
To: xemacs-beta@xemacs.org
Subject: [PATCH] 20.3-b9: fix for detach-extent crash
X-Mailer: VM 6.33 under 20.3 "Sofia" XEmacs  Lucid (beta9)
X-Face: /cA45WHG7jWq>(O3&Z57Y<"WsX5ddc,4c#w0F*zrV#=M
        0@~@,s;b,aMtR5Sqs"+nU.z^CSFQ9t`z2>W,S,]:[+2^
        Nbf6v4g>!&,7R4Ot4Wg{&tm=WX7P["9%a)_da48-^tGy
        ,qz]Z,Zz\{E.,]'EO+F)@$KtF&V

(setq s "12345") 
(setq e (make-extent 0 5 s)) 
(set-extent-property e 'duplicable t) 
(detach-extent e) 

Crash city for me.  It might not crash; you might get an odd
error message instead.  But the code is clearly treating a
pointer to a string as a pointer to a buffer.

Here's a patch.  Recommended for the 19.15 official patches.

Sun Jun 29 03:02:10 1997  Kyle Jones  <kyle_jones@wonderworks.com>

	* src/undo.c (record_extent):
	  If the extent's object is a string, just return.  We
	  can't record undo information for strings, and it is
	  very bad to reference through a string pointer as if it 
	  were a buffer pointer.

*** 1.1	1997/06/29 05:42:53
--- src/undo.c	1997/06/29 05:46:48
***************
*** 206,224 ****
  void
  record_extent (Lisp_Object extent, int attached)
  {
!   Lisp_Object buffer = Fextent_object (extent);
!   struct buffer *b = XBUFFER (buffer); /* !!#### */
!   Lisp_Object token;
  
!   if (!undo_prelude (b, 1))
!     return;
! 
!   if (attached)
!     token = extent;
    else
!     token = list3 (extent, Fextent_start_position (extent),
! 		   Fextent_end_position (extent));
!   b->undo_list = Fcons (token, b->undo_list);
  }
  
  #if 0 /* FSFmacs */
--- 206,228 ----
  void
  record_extent (Lisp_Object extent, int attached)
  {
!   Lisp_Object obj = Fextent_object (extent);
  
!   if (BUFFERP (obj))
!     {
!       Lisp_Object token;
!       struct buffer *b = XBUFFER (obj);
!       if (!undo_prelude (b, 1))
! 	return;
!       if (attached)
! 	token = extent;
!       else
! 	token = list3 (extent, Fextent_start_position (extent),
! 		       Fextent_end_position (extent));
!       b->undo_list = Fcons (token, b->undo_list);
!     }
    else
!     return;
  }
  
  #if 0 /* FSFmacs */

