Module Name: src
Committed By: christos
Date: Wed Nov 27 18:11:00 UTC 2013
Modified Files:
src/external/bsd/nvi/dist/ex: ex_cscope.c
Log Message:
CID 1132769: Fix memory leak
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_cscope.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/nvi/dist/ex/ex_cscope.c
diff -u src/external/bsd/nvi/dist/ex/ex_cscope.c:1.3 src/external/bsd/nvi/dist/ex/ex_cscope.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_cscope.c:1.3 Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/ex/ex_cscope.c Wed Nov 27 13:11:00 2013
@@ -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 @@ cscope_find(SCR *sp, EXCMD *cmdp, const
/* 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 @@ cscope_find(SCR *sp, EXCMD *cmdp, const
*/
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 @@ cscope_find(SCR *sp, EXCMD *cmdp, const
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);
}