From 89a453413252a6b652c3406316a88469098d0b83 Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 17 Jul 2010 00:00:32 +0000 Subject: [PATCH] Plug memory leak. OK nicm --- usr.bin/diff/diffdir.c | 8 +++++--- 1 file 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 @@ -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); -- 2.20.1