From 3489a85fbf86e9d4ef5e42a6cdf9ec5dd649e50b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 14 Jul 2020 03:25:56 +0200 Subject: [PATCH] Fix mem leak --- flips.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/flips.cpp b/flips.cpp index 62d10cd..e16c575 100644 --- a/flips.cpp +++ b/flips.cpp @@ -1350,16 +1350,18 @@ int flipsmain(int argc, WCHAR * argv[]) if (numargs!=2 && numargs!=3) usage(); GUIClaimConsole(); LPCWSTR outname = arg[2]; - if(!outname) + LPWSTR outname_buf = NULL; + if (!outname) { WCHAR* base_ext = GetExtension(arg[1]); int extlen = wcslen(base_ext); - LPWSTR tmp = (WCHAR*)malloc(sizeof(WCHAR)*(wcslen(arg[0])+extlen)); - wcscpy(tmp, arg[0]); - wcscpy(GetExtension(tmp), base_ext); - outname = tmp; + outname_buf = (WCHAR*)malloc(sizeof(WCHAR)*(wcslen(arg[0])+extlen)); + wcscpy(outname_buf, arg[0]); + wcscpy(GetExtension(outname_buf), base_ext); + outname = outname_buf; } struct errorinfo errinf=ApplyPatch(arg[0], arg[1], !ignoreChecksum, outname, &manifestinfo, false); + free(outname_buf); puts(errinf.description); return errinf.level; }