emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MOST_POSITIVE_FIXNUM and maximum buffer/string size


From: Eli Zaretskii
Subject: MOST_POSITIVE_FIXNUM and maximum buffer/string size
Date: Fri, 29 Apr 2011 14:35:17 +0300

This came up in the context of bug #8545, see

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8545#70

Here's the thing: we currently use MOST_POSITIVE_FIXNUM both as the
maximum value of a Lisp integer, and as a maximum size of buffers and
strings Emacs can handle.  But for a buffer that holds N characters,
buffer positions are numbered 1 to N+1, because the value of point at
EOB is N+1.  If we allow N to be as large as MOST_POSITIVE_FIXNUM, the
value of point at EOB will overflow, at least on the Lisp level, if
not in C.

Unless I'm missing something, this means we need to limit buffer sizes
to MOST_POSITIVE_FIXNUM-1.

A related issue is with strings.  String positions are zero-based, so
there's no problem with overflow there.  But if a string whose length
is MOST_POSITIVE_FIXNUM is inserted into a buffer, we will again have
an overflow.  So should we limit strings to MOST_POSITIVE_FIXNUM-1 as
well?

Admittedly, this issue is of practical importance only for 32-bit
hosts.  However, since a significant effort was invested lately by
several individuals to clean up the mess we had with using incorrect
sizes and limitations of this kind, I think it would be good to clean
up this issue as well.

Comments and opinions are welcome.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]