Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/grep Fix memory leaks.
details: https://anonhg.NetBSD.org/src/rev/97e7ccb5a614
branches: trunk
changeset: 764379:97e7ccb5a614
user: joerg <joerg%NetBSD.org@localhost>
date: Mon Apr 18 03:47:40 2011 +0000
description:
Fix memory leaks.
diffstat:
usr.bin/grep/queue.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (50 lines):
diff -r 563d2acbff9e -r 97e7ccb5a614 usr.bin/grep/queue.c
--- a/usr.bin/grep/queue.c Mon Apr 18 03:27:40 2011 +0000
+++ b/usr.bin/grep/queue.c Mon Apr 18 03:47:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: queue.c,v 1.3 2011/04/18 03:27:40 joerg Exp $ */
+/* $NetBSD: queue.c,v 1.4 2011/04/18 03:47:40 joerg Exp $ */
/* $FreeBSD: head/usr.bin/grep/queue.c 211496 2010-08-19 09:28:59Z des $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -36,7 +36,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: queue.c,v 1.3 2011/04/18 03:27:40 joerg Exp $");
+__RCSID("$NetBSD: queue.c,v 1.4 2011/04/18 03:47:40 joerg Exp $");
#include <sys/param.h>
#include <sys/queue.h>
@@ -71,8 +71,11 @@
STAILQ_INSERT_TAIL(&queue, item, list);
- if (++count > Bflag)
- free(dequeue());
+ if (++count > Bflag) {
+ item = dequeue();
+ free(item->data.dat);
+ free(item);
+ }
}
static struct qentry *
@@ -96,6 +99,7 @@
while ((item = dequeue()) != NULL) {
printline(&item->data, '-', (regmatch_t *)NULL, 0);
+ free(item->data.dat);
free(item);
}
}
@@ -105,6 +109,8 @@
{
struct qentry *item;
- while ((item = dequeue()) != NULL)
+ while ((item = dequeue()) != NULL) {
+ free(item->data.dat);
free(item);
+ }
}
Home |
Main Index |
Thread Index |
Old Index