From dc3742241db030c12758ee459d345f2da733c7fa Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Fri, 8 Jan 2010 13:28:00 +0000 Subject: Don't leak memory after strdup() in makedirs(). From Igor Zinovik; thanks! ok stsp@, millert@ --- usr.bin/patch/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 8c3f888ae66..b27b57b62c3 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.33 2009/10/27 23:59:41 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.34 2010/01/08 13:27:59 oga Exp $ */ /* * patch - a program to apply diffs to original files @@ -310,8 +310,10 @@ makedirs(const char *filename, bool striplast) if (striplast) { char *s = strrchr(tmpbuf, '/'); - if (s == NULL) + if (s == NULL) { + free(tmpbuf); return; /* nothing to be done */ + } *s = '\0'; } if (mkpath(tmpbuf) != 0) -- cgit v1.2.3