summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2006-05-24 16:43:35 +0000
committerchristos <christos@NetBSD.org>2006-05-24 16:43:35 +0000
commit04e2c897d290f4e005471537ef43cb1af6b3b831 (patch)
tree6c37b879ce4f68a8db2e3f81b9f5a193fc0eeed6 /usr.bin/patch
parenta740c3d0aa31c96a719444735d93eb858531009b (diff)
Coverity CID 3510: Don't leak memory.
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/pch.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 2810ba65f16..49b747e9d7a 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pch.c,v 1.20 2006/04/09 19:03:32 christos Exp $ */
+/* $NetBSD: pch.c,v 1.21 2006/05/24 16:43:35 christos Exp $ */
/*
* Copyright (c) 1988, Larry Wall
@@ -24,7 +24,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pch.c,v 1.20 2006/04/09 19:03:32 christos Exp $");
+__RCSID("$NetBSD: pch.c,v 1.21 2006/05/24 16:43:35 christos Exp $");
#endif /* not lint */
#include "EXTERN.h"
@@ -381,8 +381,11 @@ intuit_diff_type(void)
oldname = fetchname(oldtmp, strippath, TRUE);
old_file_is_dev_null = filename_is_dev_null;
}
- if (newtmp != NULL)
+ if (newtmp != NULL) {
+ if (newname)
+ free(newname);
newname = fetchname(newtmp, strippath, TRUE);
+ }
if (oldname && newname) {
if (strlen(oldname) < strlen(newname))
bestguess = xstrdup(oldname);