all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Subtle bugs in interval code.
Date: Fri, 23 Mar 2007 12:55:15 +0100	[thread overview]
Message-ID: <85d5302mzg.fsf@lola.goethe.zz> (raw)
In-Reply-To: <m3lkhoi3od.fsf@kfs-l.imdomain.dk> (Kim F. Storm's message of "Fri\, 23 Mar 2007 12\:45\:38 +0100")

storm@cua.dk (Kim F. Storm) writes:

> Studying the code in interval.c for merge_properties and
> intervals_equal, I noticed that they use Fmemq to search
> for a given property on a plist.
>
> That's not a safe way to do that;
>
> E.g. consider a plist like this:
>
> (setq p '(a b c d))
>
> Now,
>
>  (plist-get p 'a) => b
>  (plist-get p 'b) => nil
>
> whereas
>
>  (memq 'a p) => (a b c d)
>  (memq 'b p) => (b c d)   !=   nil
>
> So due to the use of Fmemq, the interval code may wrongly assume that
> the plist has a `b' member with a value of `c'.
>
> I'm not aware of any specific bugs related to this.
>
> Note that we cannot just use plist-get instead of memq, as we then
> cannot differentiate between "property is on list with nil value"
> and "property is not on list".

One could check whether the length of the rest sequence is even.

The cleanest option might be to add an optional DEFAULT argument to
plist-get, but that would require changes to all C level callers.
Maybe one should add an explicit plist-get-default function that takes
the default for non-existing elements from its third argument?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2007-03-23 11:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-23 11:45 Subtle bugs in interval code Kim F. Storm
2007-03-23 11:55 ` David Kastrup [this message]
2007-03-23 14:03   ` Kim F. Storm
2007-03-23 14:59 ` Johan Bockgård
2007-03-23 15:42   ` Kim F. Storm
2007-03-23 22:32 ` Richard Stallman
2007-03-25  1:19   ` Kim F. Storm
2007-03-25 17:27     ` Richard Stallman
2007-03-25 22:47       ` Kim F. Storm

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=85d5302mzg.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=storm@cua.dk \
    /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.