Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/nvi/dist/ex CID 1132769: Fix memory leak
details: https://anonhg.NetBSD.org/src/rev/ea55c5c29abe
branches: trunk
changeset: 791659:ea55c5c29abe
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 27 18:11:00 2013 +0000
description:
CID 1132769: Fix memory leak
diffstat:
external/bsd/nvi/dist/ex/ex_cscope.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diffs (54 lines):
diff -r b5dede412d6a -r ea55c5c29abe external/bsd/nvi/dist/ex/ex_cscope.c
--- a/external/bsd/nvi/dist/ex/ex_cscope.c Wed Nov 27 18:09:06 2013 +0000
+++ b/external/bsd/nvi/dist/ex/ex_cscope.c Wed Nov 27 18:11:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_cscope.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/* $NetBSD: ex_cscope.c,v 1.4 2013/11/27 18:11:00 christos Exp $ */
/*-
* Copyright (c) 1994, 1996
* Rob Mayoff. All rights reserved.
@@ -503,14 +503,14 @@
/* Read the output. */
if (parse(sp, csc, tqp, &matches)) {
- if (rtqp != NULL)
- free(rtqp);
+ free(rtqp);
tagq_free(sp, tqp);
return (1);
}
}
if (matches == 0) {
+ free(rtqp);
msgq(sp, M_INFO, "278|No matches for query");
return (0);
}
@@ -537,8 +537,10 @@
*/
if (TAILQ_EMPTY(&exp->tq)) {
TAILQ_INSERT_HEAD(&exp->tq, rtqp, q);
- } else
+ } else {
+ free(rtqp);
rtqp = TAILQ_FIRST(&exp->tq);
+ }
/* Link the current TAGQ structure into place. */
TAILQ_INSERT_HEAD(&exp->tq, tqp, q);
@@ -568,12 +570,9 @@
err:
alloc_err:
- if (rtqp != NULL)
- free(rtqp);
- if (rtp != NULL)
- free(rtp);
- if (np != NULL)
- free(__UNCONST(np));
+ free(rtqp);
+ free(rtp);
+ free(__UNCONST(np));
return (1);
}
Home |
Main Index |
Thread Index |
Old Index