From 5d96bf2cf0c00a9864ebab28d7c4f6fcdbc21812 Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 9 Apr 2006 19:21:26 +0000 Subject: Coverity CID 2333: Fix memory leak. --- usr.bin/error/pi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'usr.bin/error') diff --git a/usr.bin/error/pi.c b/usr.bin/error/pi.c index 2107907e55e..94efd954257 100644 --- a/usr.bin/error/pi.c +++ b/usr.bin/error/pi.c @@ -1,4 +1,4 @@ -/* $NetBSD: pi.c,v 1.11 2003/08/07 11:13:38 agc Exp $ */ +/* $NetBSD: pi.c,v 1.12 2006/04/09 19:21:26 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,12 +34,13 @@ #if 0 static char sccsid[] = "@(#)pi.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: pi.c,v 1.11 2003/08/07 11:13:38 agc Exp $"); +__RCSID("$NetBSD: pi.c,v 1.12 2006/04/09 19:21:26 christos Exp $"); #endif /* not lint */ #include #include #include +#include #include "error.h" static char *c_linenumber; @@ -317,6 +318,10 @@ pi(void) ){ for (wordindex = undefined ? 5 : 6; wordindex <= wordc; wordindex++){ + if (nwordv) { + free(nwordv[0]); + free(nwordv); + } nwordv = wordvsplice(2, undefined ? 2 : 3, wordv+1); nwordv[0] = strdup(currentfilename); nwordv[1] = wordv[wordindex]; -- cgit