xcopy: Fix some memory leaks
Andrew Talbot
andrew.talbot at talbotville.com
Wed Oct 24 16:02:43 CDT 2007
Changelog:
xcopy: Fix some memory leaks.
diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c
index a88a0ad..6a1e8bf 100644
--- a/programs/xcopy/xcopy.c
+++ b/programs/xcopy/xcopy.c
@@ -507,6 +507,7 @@ static int XCOPY_DoCopy(WCHAR *srcstem,
BOOL copiedFile = FALSE;
DWORD destAttribs, srcAttribs;
BOOL skipFile;
+ int ret = 0;
/* Allocate some working memory on heap to minimize footprint */
finddata = HeapAlloc(GetProcessHeap(), 0, sizeof(WIN32_FIND_DATA));
@@ -718,7 +719,8 @@ static int XCOPY_DoCopy(WCHAR *srcstem,
if (flags & OPT_IGNOREERRORS) {
skipFile = TRUE;
} else {
- return RC_WRITEERROR;
+ ret = RC_WRITEERROR;
+ goto cleanup;
}
}
@@ -780,12 +782,14 @@ static int XCOPY_DoCopy(WCHAR *srcstem,
}
}
+cleanup:
+
/* free up memory */
HeapFree(GetProcessHeap(), 0, finddata);
HeapFree(GetProcessHeap(), 0, inputpath);
HeapFree(GetProcessHeap(), 0, outputpath);
- return 0;
+ return ret;
}
/* =========================================================================
More information about the wine-patches
mailing list