GNU bug report logs - #78690
31.0.50; split string: args out of range with TRIM

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Wed, 4 Jun 2025 02:35:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 78690 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 78690 <at> debbugs.gnu.org
Subject: Re: bug#78690: 31.0.50; split string: args out of range with TRIM
Date: Thu, 05 Jun 2025 18:48:44 +0300
> Date: Wed, 04 Jun 2025 04:36:26 +0200
> From:  Michael Heerdegen via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> 
> Hello,
> 
> I stumbled across this:
> 
> #+begin_src emacs-lisp
> (split-string
>  "-*- lexical-binding: t; -*-"
>  "-\\*-" nil "[ \t\n\r-]+")
> #+end_src
> 
> ~~>
> 
> | Debugger entered--Lisp error: (args-out-of-range "-*- lexical-binding: t; -*-" 1 0)
> |   (substring "-*- lexical-binding: t; -*-" 1 0)
> |   (let ((this (substring string this-start this-end))) (if trim (progn (let ((tem (string-match (concat trim "\\'") this 0))) (and tem (< tem (length this)) (setq this (substring this 0 tem)))))) (if (or keep-nulls (> (length this) 0)) (progn (setq list (cons this list)))))

It is quite obvious that split-string is not prepared to deal with a
situation where the argument STRING begins with a match for
SEPARATORS.  The breakage here happens because the match for
SEPARATORS at the very beginning of STRING also matches TRIM, but even
if that is not so, a match for SEPARATORS at the beginning of STRING
sets THIS-START incorrectly for the first call to push-one inside the
while-loop.




This bug report was last modified 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.