Subject: bug#13098: [PATCH] cut.c: Fix memory leak

From: Jim Meyering <[email-masked]>
Date: Fri, 07 Dec 2012 05:32:53 +0100

Pádraig Brady wrote:
...
> How about the attached?

> From: Cojocaru Alexandru <[email-masked]>
> Date: Thu, 6 Dec 2012 03:03:41 +0100
> Subject: [PATCH] cut: avoid a redundant heap allocation
>
> * src/cut.c (set_fields): Don't allocate memory for
> `printable_field' if there are no finite ranges.
> The extra allocation was introduced via commit v8.10-3-g2e636af.
...

Thanks to both of you.
That's a fine bug fix, actually.
Consider that before, this would fail on my 64-bit system:

    $ : | cut -b999999999999999999-
    cut: memory exhausted
    [Exit 1]
    $

Now, it no longer tries to allocate all that memory, so completes normally:

    $ : | cut -b999999999999999999-
    $