Re: [PATCH 20/22] match-trees: fix leaking prefixes in `shift_tree()`

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

 



Patrick Steinhardt <ps@xxxxxx> writes:

> In `shift_tree()` we allocate two empty strings that we end up
> passing to `match_trees()`. If that function finds a better match it
> will update these pointers to point to a newly allocated strings,
> freeing the old strings. We never free the final results though, neither
> the ones we have allocated ourselves, nor the one that `match_trees()`
> might've returned to us.
>
> Fix the resulting memory leaks by creating a common exit path where we
> free them.
>
> Signed-off-by: Patrick Steinhardt <ps@xxxxxx>
> ---
>  match-trees.c            | 10 +++++++---
>  t/t6409-merge-subtree.sh |  1 +
>  2 files changed, 8 insertions(+), 3 deletions(-)

We are not going to take the "best_match" out of this
function, so somebody ought to free it, and that somebody must be
this function.

Makes sense.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux