summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/diffdir.c
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2010-07-17 00:00:32 +0000
committerray <ray@openbsd.org>2010-07-17 00:00:32 +0000
commit89a453413252a6b652c3406316a88469098d0b83 (patch)
tree9ac1c52f6c71174129a01e01185bab2eca114641 /usr.bin/diff/diffdir.c
parentSimplify print_status by removing NULL handling. (diff)
downloadwireguard-openbsd-89a453413252a6b652c3406316a88469098d0b83.tar.xz
wireguard-openbsd-89a453413252a6b652c3406316a88469098d0b83.zip
Plug memory leak.
OK nicm
Diffstat (limited to 'usr.bin/diff/diffdir.c')
-rw-r--r--usr.bin/diff/diffdir.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c
index 073b1fd0206..5105fbad96a 100644
--- a/usr.bin/diff/diffdir.c
+++ b/usr.bin/diff/diffdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffdir.c,v 1.36 2010/07/16 23:27:58 ray Exp $ */
+/* $OpenBSD: diffdir.c,v 1.37 2010/07/17 00:00:32 ray Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -81,8 +81,9 @@ diffdir(char *p1, char *p2, int flags)
/* get a list of the entries in each directory */
dp1 = dirp1 = slurpdir(path1, &dirbuf1, Nflag + Pflag);
dp2 = dirp2 = slurpdir(path2, &dirbuf2, Nflag);
- if (dirp1 == NULL || dirp2 == NULL)
- return;
+ if (dirp1 == NULL || dirp2 == NULL) {
+ goto closem;
+ }
/*
* If we were given a starting point, find it.
@@ -144,6 +145,7 @@ diffdir(char *p1, char *p2, int flags)
}
}
+closem:
if (dirbuf1 != NULL) {
xfree(dirp1);
xfree(dirbuf1);