Andrew Talbot : xcopy: Fix some memory leaks.

Alexandre Julliard julliard at winehq.org
Thu Oct 25 08:38:56 CDT 2007


Module: wine
Branch: master
Commit: a8df7fddd54b865564a230e8aa13c45a655e48ba
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a8df7fddd54b865564a230e8aa13c45a655e48ba

Author: Andrew Talbot <andrew.talbot at talbotville.com>
Date:   Wed Oct 24 22:02:43 2007 +0100

xcopy: Fix some memory leaks.

---

 programs/xcopy/xcopy.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

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, WCHAR *srcspec,
     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, WCHAR *srcspec,
                     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, WCHAR *srcspec,
         }
     }
 
+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-cvs mailing list