all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Potential GC-related problems in compose_chars_in_text
Date: Mon, 12 Sep 2005 14:41:51 +0200	[thread overview]
Message-ID: <m3mzmixxtc.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <E1EEceq-0000U4-00@etlken> (Kenichi Handa's message of "Mon, 12 Sep 2005 09:58:52 +0900")


The following code in compose_chars_in_text looks suspicious:

	      if (INTEGERP (val) && XFASTINT (val) == start)
		{
		  to = Fmatch_end (make_number (0));
		  val = call4 (XCDR (elt), val, to, XCAR (elt), string);
		  if (INTEGERP (val) && XINT (val) > 1)
		    {
		      start += XINT (val);
		      if (STRINGP (string))
			ptr = SDATA (string) + string_char_to_byte (string, start);
		      else
			ptr = CHAR_POS_ADDR (start);
		    }
		  else
		    {
		      start++;
		      ptr += len;
>>>> if string is non-nil, and call4 did GC, then ptr may no longer
>>>> point into "string".
		    }
		  break;

Likewise, the `pend' pointer may no longer be valid for the same reason
-- on both branches of the above code!!.


Furthermore, the initialization of pend seems bogus too:

      ptr = SDATA (string) + string_char_to_byte (string, start);
      pend = ptr + SBYTES (string);

Shouldn't that be

      pend = SDATA (string) + SBYTES (string);


Here is a patch (untested):

*** composite.c	14 Aug 2005 14:47:27 +0200	1.35
--- composite.c	12 Sep 2005 14:40:52 +0200	
***************
*** 616,622 ****
        GCPRO1 (string);
        stop = end;
        ptr = SDATA (string) + string_char_to_byte (string, start);
!       pend = ptr + SBYTES (string);
      }
    else
      {
--- 616,622 ----
        GCPRO1 (string);
        stop = end;
        ptr = SDATA (string) + string_char_to_byte (string, start);
!       pend = SDATA (string) + SBYTES (string);
      }
    else
      {
***************
*** 680,689 ****
  		    {
  		      start += XINT (val);
  		      if (STRINGP (string))
! 			ptr = SDATA (string) + string_char_to_byte (string, start);
  		      else
  			ptr = CHAR_POS_ADDR (start);
  		    }
  		  else
  		    {
  		      start++;
--- 680,698 ----
  		    {
  		      start += XINT (val);
  		      if (STRINGP (string))
! 			{
! 			  ptr = SDATA (string) + string_char_to_byte (string, start);
! 			  pend = SDATA (string) + SBYTES (string);
! 			}
  		      else
  			ptr = CHAR_POS_ADDR (start);
  		    }
+ 		  else if (STRINGP (string))
+ 		    {
+ 		      start++;
+ 		      ptr = SDATA (string) + string_char_to_byte (string, start);
+ 		      pend = SDATA (string) + SBYTES (string);
+ 		    }
  		  else
  		    {
  		      start++;

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  parent reply	other threads:[~2005-09-12 12:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-12  0:58 potential bug in display_mode_element? Kenichi Handa
2005-09-12  8:04 ` Kim F. Storm
2005-09-12 11:54   ` Kenichi Handa
2005-09-12 12:41 ` Kim F. Storm [this message]
2005-09-13  1:08   ` Potential GC-related problems in compose_chars_in_text Kenichi Handa
2005-09-13 15:54   ` Richard M. Stallman
2005-09-14  7:29     ` Kenichi Handa
2005-09-15  2:41       ` Richard M. Stallman
2005-09-15  4:21         ` Kenichi Handa
2005-09-16  1:01           ` Richard M. Stallman
2005-09-16 15:39             ` Stefan Monnier
2005-09-17 13:39               ` Richard M. Stallman
2005-09-19 13:43                 ` Stefan Monnier
2005-09-12 15:34 ` potential bug in display_mode_element? Richard M. Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3mzmixxtc.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.