[Bug 195929] usr.bin/sed -- eliminate one malloc and add consts

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Dec 13 00:07:04 UTC 2014


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195929

Mikhail T. <mi at ALDAN.algebra.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #150516|0                           |1
        is obsolete|                            |

--- Comment #2 from Mikhail T. <mi at ALDAN.algebra.com> ---
Created attachment 150518
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=150518&action=edit
Constify, remove command-length limits

This patch purports to eliminate the use of static buffers (of size
_POSIX2_LINE_MAX -- 2048).

They are replaced by either dynamically-allocated memory (when reading from
file using getline() instead fgets()) and by using the already-recorded
strings, when those are given on command-line (-e).

This saves run-time memory -- because most commands are much shorter than 2048,
while also lifting the hard-limit for those cases, when a command is longer...

The latter case was handled badly before -- the command was silently truncated
leading to cryptic error messages at best (see Bug 177018) or to a possible
corruption at worst.

Tested (under valgrind) against math.sed and hanoi.sed, as well as the very
long -e argument.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list