sed 4.2.1 bug

Sophia Jacob <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <CAOsEXddeJJ-1vJuNTn0vVL0C0wJAjr2N+=a=wdJkLq7RZBYY=A@mail.gmail.com>
Hi,
I stumbled upon a possible bug in sed:

$ cat c
1
2
3
4
5

$ sed -n 'H;4,${g;D;h}' c   # print the last 3 lines of a file
sed: couldn't re-allocate memory

Basically, if 'D' is used after 'g' or 'G' or 'x' (after copying from
the hold space), this realloc error is thrown. I think this is a bug.
Please let me know if this is a usage error on my part.

-------
($ sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <[email protected]>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
)
-------
(I couldn't analyze the source code because I'm not permitted to look
at any open-source product's (or any product other than my
organization's) source code. Sorry I'm not able to help.)

Thanks!
Sophia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.