Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: fix memory leak in Lst_Remove (since 2020...
details: https://anonhg.NetBSD.org/src/rev/36d0f39f50fc
branches: trunk
changeset: 362026:36d0f39f50fc
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 26 11:57:21 2022 +0000
description:
make: fix memory leak in Lst_Remove (since 2020-10-23)
The code to free the list node (as opposed to the node data) was
accidentally removed in lst.c 1.83 from 2020-10-23 as part of cleaning
up an unnecessarily complicated function for traversing linked lists.
The memory leak only affected a few lists that actually used Lst_Remove.
Most lists are append-only and are freed using Lst_Done or Lst_Free at
the end, which correctly free the memory.
diffstat:
usr.bin/make/lst.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (27 lines):
diff -r 37e98c23a0c8 -r 36d0f39f50fc usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Sat Feb 26 11:13:01 2022 +0000
+++ b/usr.bin/make/lst.c Sat Feb 26 11:57:21 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.105 2021/03/15 16:45:30 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
#include "make.h"
-MAKE_RCSID("$NetBSD: lst.c,v 1.105 2021/03/15 16:45:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $");
static ListNode *
LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -163,6 +163,8 @@
list->first = ln->next;
if (list->last == ln)
list->last = ln->prev;
+
+ free(ln);
}
/* Replace the datum in the given node with the new datum. */
Home |
Main Index |
Thread Index |
Old Index